Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-137721

Hard to read the text of Default Button within a Popup Widget.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.7
    • GUI: Painting
    • None
    • macOS Sonoma 14.7.6
      Qt 6.7
    • macOS

    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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            Sajas01 Sajas K K
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes