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

QPushButton: incorrect placement of icon and menu

    XMLWordPrintable

Details

    Description

      When placing an icon and a menu on a QPushButton, there is a huge margin on the left.

      #include <QtGui>
      
      #define ICON QIcon::fromTheme("edit-cut")
      
      int main ( int argc, char **argv )
      {
          QApplication app(argc ,argv);
      
          QWidget w;
      
          QVBoxLayout *vlay = new QVBoxLayout(&w);
          QHBoxLayout *hlay;
          QPushButton *pb;
          QMenu *m;
      
          hlay = new QHBoxLayout;
          vlay->addLayout(hlay);
          pb = new QPushButton(QString("this is button 1"), &w);
          hlay->addWidget(pb);
          hlay->addStretch(1);
      
      
          hlay = new QHBoxLayout;
          vlay->addLayout(hlay);
          pb = new QPushButton(QString("this is button 2"), &w);
          pb->setIcon(QIcon(ICON));
          hlay->addWidget(pb);
          hlay->addStretch(1);
      
          hlay = new QHBoxLayout;
          vlay->addLayout(hlay);
          pb = new QPushButton(QString("this is button 3"), &w);
      
          m = new QMenu(&w);
          m->addAction(QString("Action 1"));
          m->addAction(QString("Action 2"));
          m->addAction(QString("Action 3"));
          pb->setMenu(m);
      
          hlay->addWidget(pb);
          hlay->addStretch(1);
      
          hlay = new QHBoxLayout;
          vlay->addLayout(hlay);
          pb = new QPushButton(QString("this is button 4"), &w);
          pb->setIcon(QIcon(ICON));
      
          m = new QMenu(&w);
          m->addAction(QString("Action 1"));
          m->addAction(QString("Action 2"));
          m->addAction(QString("Action 3"));
      
          pb->setMenu(m);
          hlay->addWidget(pb);
          hlay->addStretch(1);
      
          w.show();
          return app.exec();
      }
      
      
      

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            cattell Matthew Cattell (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes