Skip to content

CDockWidget tab breaks QComboBox popup #822

@dp-buhl

Description

@dp-buhl

Description

When a QComboBox is placed inside a widget hosted by ads::CDockWidget / ads::CDockManager, the combo box popup is displayed with incorrect positioning.

Instead of opening directly below the combo box, the popup become visually detached from the combo box.

The issue does not occur when using a regular QTabWidget with the same content widget.

Steps to reproduce

  1. Run the example with ads = true.
  2. Open Tab 2 if not open.
  3. Click the QComboBox to open the popup.
  4. Open Tab 1.
  5. Return to Tab 2.
  6. Click the QComboBox to open the popup again.
  7. Observe the wrong popup placement.

Expected behavior
The QComboBox popup should open directly below the combo box, with the usual size and alignment.

Additional information

  1. If the same content is shown inside a normal QTabWidget (ads = false), the popup behaves correctly.
  2. If the Mainwindow is moved, the distance between the popup and the combobox seems to be the same as the distance between the screen origin and the mainwindow origin.

Minimal reproducible example

#include <QApplication>

#include <QMainWindow>

#include <QVBoxLayout>
#include <QComboBox>

#include "DockManager.h"
#include "DockWidget.h"
#include "DockAreaWidget.h"

class ComboboxContentWidget : public QWidget
{
   Q_OBJECT

public:

   ComboboxContentWidget( QWidget* parent = nullptr ) : QWidget( parent )
   {
      auto* mainLayout = new QVBoxLayout;

      auto* combo = new QComboBox( this );
      combo->addItems( { "Entry 1", "Entry 2", "Entry 3" } );

      mainLayout->addWidget( combo );
      mainLayout->addStretch( 1 );

      setLayout( mainLayout );
   }

   ~ComboboxContentWidget() = default;
};

class TestWindow : public QMainWindow
{
   Q_OBJECT

public:

   TestWindow( QWidget* parent = nullptr ) : QMainWindow( parent )
   {
      resize( 800, 500 );

      const bool ads = true;

      if ( ads )
      {

         auto* dockManager = new ads::CDockManager( this );
         setCentralWidget( dockManager );

         auto* dock1 = new ads::CDockWidget( dockManager, "Tab 1", dockManager );

         auto* dock2 = new ads::CDockWidget( dockManager, "Tab 2", dockManager );
         dock2->setWidget( new ComboboxContentWidget );

         auto* area = dockManager->addDockWidget( ads::CenterDockWidgetArea, dock1 );
         dockManager->addDockWidget( ads::CenterDockWidgetArea, dock2, area );
      }
      else
      {
         auto* centralWidget = new QTabWidget( this );
         setCentralWidget( centralWidget );

         auto* tab1 = new QWidget( this );
         auto* tab2 = new ComboboxContentWidget( this );

         centralWidget->addTab( tab1, "Tab 1" );
         centralWidget->addTab( tab2, "Tab 2" );
      }
   }

   ~TestWindow() override = default;
};



int main( int argc, char* argv[] )
{
   QApplication app( argc, argv );
   TestWindow window;

   window.move( 0, 20 );
   window.show();

   return app.exec();
}

#include "main.moc"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions