forked from mfreiholz/Qt-Advanced-Docking-System
-
Notifications
You must be signed in to change notification settings - Fork 681
Open
Description
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
- Run the example with ads = true.
- Open Tab 2 if not open.
- Click the QComboBox to open the popup.
- Open Tab 1.
- Return to Tab 2.
- Click the QComboBox to open the popup again.
- 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
- If the same content is shown inside a normal QTabWidget (ads = false), the popup behaves correctly.
- 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"
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels