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

Configuring border for QPushButton:default state clips the text on a button inside QMessageBox

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.2, 6.3.1
    • Widgets: Style Sheets
    • None
    • Windows

    Description

      I'm seeing weird effects of

      QPushButton:default {border: ...}
      

      As well as weird interaction of the 'border' property with 'padding'.

      Here's what the problem looks like:

      As you can see, the default button highlight border is clipping the text. And padding seems to have a weird reverse effect on the dotted input focus frame - the frame seems to shrink as you increase padding.
      Here's the repro. The commented out part tests buttons outside of a message box, which shows the weird sizing of the dotted focus frame as well, but there is no text clipping. That only happens in a message box.

      #include <QApplication>
      #include <QMessageBox>
      #include <QPushButton>
      #include <QVBoxLayout>
      
      static const QString style = R"(
      QPushButton {
      	padding: 4px;
      }
      
      QPushButton:default {
      	border: 2px solid #800000;
      	/*padding: 4px;*/
      }
      )";
      
      static void showMsgBox() {
      	QMessageBox m;
      	m.addButton("Upgrade", QMessageBox::YesRole);
      	m.addButton("QfgqM", QMessageBox::NoRole);
      	m.exec();
      }
      
      int main(int argc, char *argv[]) {
      	QApplication a(argc, argv);
      	a.setStyleSheet(style);
      	showMsgBox();
      
      //	QWidget w;
      //	auto l = new QVBoxLayout;
      //	auto spacer = new QWidget;
      //	spacer->setFixedSize(200, 50);
      //	l->addWidget(spacer);
      //	auto btn = new QPushButton("Upgrade fgpq");
      //	l->addWidget(btn);
      //	l->addWidget(new QPushButton("Second fgpq"));
      //	w.setLayout(l);
      //	w.show();
      //	QObject::connect(btn, &QPushButton::clicked, &showMsgBox);
      	return a.exec();
      }
      

      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
            alexium Alex
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes