Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.6.2, 6.7.0 Beta3
-
MacOS Sonoma 14.3.1
Description
I got QMainWindow with WA_TranslucentBackground. I want to hide and show some elements in its layout. It looks like the layout or background doesn't repaint after hiding the widget.
Before hiding btn2:
After hiding btn2:
I made a sample to demonstrate this:
MainWindow.h:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "QtWidgets/qboxlayout.h"
#include "QtWidgets/qpushbutton.h"
#include "ui_mainwindow.h"
#include <QMainWindow>
QT_BEGIN_NAMESPACE
namespace Ui
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
QWidget *centralWidget;
QVBoxLayout *btnsLayout;
QPushButton *btn1;
QPushButton *btn2;
Ui::MainWindow *ui;
public:
MainWindow(QWidget *parent = nullptr)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
~MainWindow() { delete ui; }
public slots:
void onBtnClick(bool)
};
#endif // MAINWINDOW_H
I'm ok with the layout moving btn1, but I need to get rid of the "shadows" of the buttons.
I tried removeWidget(btn2), delete btn2, btnsLayout->update(), MainWindow::update(), and repaint(), nothing helps.
The only workaround I found is to hide and show or resize the entire main window (commented out part), but I think there's gotta be a better way.