Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QComboBox Fails to Display Dropdown When Placed in QGraphicsView via QGraphicsProxyWidget
Qt 6.11 is out! See what's new in the release blog

QComboBox Fails to Display Dropdown When Placed in QGraphicsView via QGraphicsProxyWidget

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Momo.Dai
    wrote on last edited by
    #1

    Hello,
    I was using QGraphicsView with QGraphicsScene and tried adding a QComboBox inside, with just a simple implementation.
    Although I googled many related issues online, I couldn't find complete information to solve the problem.

    Below is a simple implementation of my MainWindow:

    MainWIndows

    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
        , ui(new Ui::MainWindow) {
        ui->setupUi(this);
    
        setupWidgets();
        setupGraphicsView();
    }
    
    ..
    ..
    ..
    
    void MainWindow::setupGraphicsView() {
        m_graphicsView = new QGraphicsView(this);
        m_scene = new QGraphicsScene(this);
        m_graphicsView->setScene(m_scene);
        setCentralWidget(m_graphicsView);
    
        QComboBox *cbx = new QComboBox();
        cbx->addItem("00");
        cbx->addItem("01");
        cbx->addItem("02");
    
        QGraphicsProxyWidget *proxyWidgetCB = m_scene->addWidget(cbx);
        proxyWidgetCB->setPos(20, 20);
    
        m_scene->setSceneRect(0, 0, 1280, 720);
        m_graphicsView->setFixedSize(1280, 720);
    }
    

    In a Windows 10 environment, the dropdown menu looks normal.
    e6d0da8c-3189-4802-b126-d0f720300a0d-image.png

    However, in Windows 11, although it turns gray when clicked, the list is not visible. But clicking directly below it switches the items, which suggests that the list is hidden?
    b067339a-931c-4516-84b2-2ab15bd7645e-image.png

    Is this a bug in Windows 11 or a Qt bug?

    Test environments:
    OS Versions:

    • Windows 10 Pro, 22H2 (19045.2965)
    • Windows 11 Pro, 23H2 (22631.4037)
      QT Versions:
      e73d9ba5-bf48-459b-a83e-d53eebf4a917-image.png
    Pl45m4P 1 Reply Last reply
    0
    • M Momo.Dai

      Hello,
      I was using QGraphicsView with QGraphicsScene and tried adding a QComboBox inside, with just a simple implementation.
      Although I googled many related issues online, I couldn't find complete information to solve the problem.

      Below is a simple implementation of my MainWindow:

      MainWIndows

      MainWindow::MainWindow(QWidget *parent)
          : QMainWindow(parent)
          , ui(new Ui::MainWindow) {
          ui->setupUi(this);
      
          setupWidgets();
          setupGraphicsView();
      }
      
      ..
      ..
      ..
      
      void MainWindow::setupGraphicsView() {
          m_graphicsView = new QGraphicsView(this);
          m_scene = new QGraphicsScene(this);
          m_graphicsView->setScene(m_scene);
          setCentralWidget(m_graphicsView);
      
          QComboBox *cbx = new QComboBox();
          cbx->addItem("00");
          cbx->addItem("01");
          cbx->addItem("02");
      
          QGraphicsProxyWidget *proxyWidgetCB = m_scene->addWidget(cbx);
          proxyWidgetCB->setPos(20, 20);
      
          m_scene->setSceneRect(0, 0, 1280, 720);
          m_graphicsView->setFixedSize(1280, 720);
      }
      

      In a Windows 10 environment, the dropdown menu looks normal.
      e6d0da8c-3189-4802-b126-d0f720300a0d-image.png

      However, in Windows 11, although it turns gray when clicked, the list is not visible. But clicking directly below it switches the items, which suggests that the list is hidden?
      b067339a-931c-4516-84b2-2ab15bd7645e-image.png

      Is this a bug in Windows 11 or a Qt bug?

      Test environments:
      OS Versions:

      • Windows 10 Pro, 22H2 (19045.2965)
      • Windows 11 Pro, 23H2 (22631.4037)
        QT Versions:
        e73d9ba5-bf48-459b-a83e-d53eebf4a917-image.png
      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @Momo-Dai said in QComboBox Fails to Display Dropdown When Placed in QGraphicsView via QGraphicsProxyWidget:

      Is this a bug in Windows 11 or a Qt bug?

      If I remember correctly there were/are some issues with the Windows 11 "style" and Qt6...
      Where it doesn't draw widget content and borders correctly.
      Don't know what widgets are affected exactly... but could be this case here.

      You could try another style (e.g. windows vista) on Windows 11 and check if the error persists.

      Here is one of the topics where it was mentioned.


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      M 1 Reply Last reply
      1
      • Pl45m4P Pl45m4

        @Momo-Dai said in QComboBox Fails to Display Dropdown When Placed in QGraphicsView via QGraphicsProxyWidget:

        Is this a bug in Windows 11 or a Qt bug?

        If I remember correctly there were/are some issues with the Windows 11 "style" and Qt6...
        Where it doesn't draw widget content and borders correctly.
        Don't know what widgets are affected exactly... but could be this case here.

        You could try another style (e.g. windows vista) on Windows 11 and check if the error persists.

        Here is one of the topics where it was mentioned.

        M Offline
        M Offline
        Momo.Dai
        wrote on last edited by
        #3

        @Pl45m4

        Thank you very much for your response.
        I tried setting the Windows Vista style before creating the QApplication.

        #include "mainwindow.h"
        
        #include <QApplication>
        #include <QStyleFactory>
        
        int main(int argc, char *argv[]) {
        
        #if defined(Q_OS_WINDOWS)
            QApplication::setStyle(QStyleFactory::create("windowsvista"));
        #endif
        
            QApplication a(argc, argv);
            MainWindow w;
            w.show();
            return a.exec();
        }
        

        It seems that with this setting, the dropdown menu is displayed correctly.
        87c4e752-b1a9-457b-9174-bbc0a4732eab-image.png

        Pl45m4P 1 Reply Last reply
        1
        • M Momo.Dai has marked this topic as solved on
        • M Momo.Dai

          @Pl45m4

          Thank you very much for your response.
          I tried setting the Windows Vista style before creating the QApplication.

          #include "mainwindow.h"
          
          #include <QApplication>
          #include <QStyleFactory>
          
          int main(int argc, char *argv[]) {
          
          #if defined(Q_OS_WINDOWS)
              QApplication::setStyle(QStyleFactory::create("windowsvista"));
          #endif
          
              QApplication a(argc, argv);
              MainWindow w;
              w.show();
              return a.exec();
          }
          

          It seems that with this setting, the dropdown menu is displayed correctly.
          87c4e752-b1a9-457b-9174-bbc0a4732eab-image.png

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by Pl45m4
          #4

          @Momo-Dai

          I dont know in what patch it will be fixed for Qt6.7, but the vista style might be a solution in the meantime.
          When it's fixed and you upgrade your Qt, it should work with the correct Windows 11 style


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt
          • Unsolved