Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.7
-
None
-
macOS Sonoma 14.7.6
Qt 6.7
Description
The default QPushButton within a QWidget with Qt::Popup flag set, ends up with a white text without the usual Blue Background fill. This makes it hard to read the text on the button.
#include <QApplication> #include <QDialogButtonBox> #include <QPushButton> #include <QVBoxLayout> #include <QWidget> #include <QDebug> namespace { class Popover final : public QWidget { public: Popover( QWidget * inParent ) : QWidget( inParent ) { setWindowFlags( windowFlags() | Qt::Popup ); setMinimumSize( 300, 100 ); auto * buttonBox = new QDialogButtonBox( this ); auto chooseButton = new QPushButton( "Choose", this ); auto * cancelButton = new QPushButton( "Cancel", this ); buttonBox->addButton( chooseButton, QDialogButtonBox::AcceptRole ); buttonBox->addButton( cancelButton, QDialogButtonBox::RejectRole ); auto * layout = new QVBoxLayout; layout->addWidget( buttonBox ); setLayout( layout ); connect( chooseButton, &QPushButton::clicked, [this]{ hide(); } ); connect( cancelButton, &QPushButton::clicked, [this]{ hide(); } ); } }; class MainWidget : public QWidget { public: MainWidget( QWidget * inParent ) : QWidget( inParent ) { setWindowTitle("Custom FocusFrame Example"); setGeometry(100, 100, 400, 200); auto * buttonBox = new QDialogButtonBox( this ); auto button = new QPushButton( "Open PopOver", this ); buttonBox->addButton( button, QDialogButtonBox::AcceptRole ); auto popover = new Popover(this); // Create a layout auto layout = new QVBoxLayout(this); layout->addWidget(buttonBox); connect( button, &QPushButton::clicked, [popover]{ popover->show();} ); } }; } int main(int argc, char *argv[]) { QApplication app(argc, argv); // Create the main widget auto mainWidget = new MainWidget(nullptr); mainWidget->show(); return app.exec(); }
If I set the WindowFlag to something else(for instance 'Qt::Dialog') I get the blue fill for the button.