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

Qt5.12.0 QAction is uneven after setting QMenu style

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 5.12.0
    • None
    • MacOS10.12.6
    • macOS

      normal:

      QMenu* m_pContextMenu = new QMenu;
      if(m_pContextMenu == NULL)
      {
          return;
      }
      
      QAction *a1 = new QAction(QObject::tr("one"), this);
      QAction *a2 = new QAction(QObject::tr("two"), this);
      QAction *a3 = new QAction(QObject::tr("three"), this);
      QAction *a4 = new QAction(QObject::tr("four"), this);
      QAction *a5 = new QAction(QObject::tr("five"), this);
      QAction *a6 = new QAction(QObject::tr("six"), this);
      a1->setCheckable(true);
      a1->setChecked(true);
      a5->setCheckable(true);
      a5->setChecked(true);
      
      m_pContextMenu->addAction(a1);
      m_pContextMenu->addAction(a2);
      m_pContextMenu->addAction(a3);
      m_pContextMenu->addAction(a4);
      m_pContextMenu->addAction(a5);
      m_pContextMenu->addAction(a6);
      m_pContextMenu->move(400,300);
      m_pContextMenu->show();
      

      abnormal:

      QMenu* m_pContextMenu = new QMenu;
      if(m_pContextMenu == NULL)
      {
          return;
      }
      
      //This setting results in an untidy layout
      
      m_pContextMenu->setStyleSheet(
                                    "padding: 5px 30px 5px 30px;"
                                    "border: 1px solid transparent;"
                                    "}");
      
      QAction *a1 = new QAction(QObject::tr("one"), this);
      QAction *a2 = new QAction(QObject::tr("two"), this);
      QAction *a3 = new QAction(QObject::tr("three"), this);
      QAction *a4 = new QAction(QObject::tr("four"), this);
      QAction *a5 = new QAction(QObject::tr("five"), this);
      QAction *a6 = new QAction(QObject::tr("six"), this);
      a1->setCheckable(true);
      a1->setChecked(true);
      a5->setCheckable(true);
      a5->setChecked(true);
      
      m_pContextMenu->addAction(a1);
      m_pContextMenu->addAction(a2);
      m_pContextMenu->addAction(a3);
      m_pContextMenu->addAction(a4);
      m_pContextMenu->addAction(a5);
      m_pContextMenu->addAction(a6);
      m_pContextMenu->move(400,300);
      m_pContextMenu->show();
      

        1. abnormal.png
          abnormal.png
          8 kB
        2. normal.png
          normal.png
          9 kB
        3. testQAction.tar
          29 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            chehrlic Christian Ehrlicher
            wuyu 刘 生
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes