Combobox and menu not closed when switching windows
-
Hi
I have written a qt toolbar with QCombobox and control menu on MAC. But when I switch windows, I find that the QCombobox options and popup submenus are always at the top of the screen and do not collapse automatically. I've tried adding close QCombobox and menu after losing focus, but it doesn't work.
How to solve this problem?
Thanks!QT 5.15.12
MacOS 14.0.0The code is:
MyQComboBox::MyQComboBox(QWidget *parent) : QComboBox(parent)
{
this->setView(new QListView());
this->setStyle(QStyleFactory::create("Windows"));
this->view()->window()->setWindowFlags(Qt::Popup | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint);
this->view()->window()->setAttribute(Qt::WA_TranslucentBackground);
}SkinComboBox = new MyQComboBox();
SkinComboBox->setObjectName("SkinComboBox");
SkinComboBox->addItem(tr("widget.settings.skin.light"));
SkinComboBox->addItem(tr("widget.settings.skin.dark")); -
Hi
I have written a qt toolbar with QCombobox and control menu on MAC. But when I switch windows, I find that the QCombobox options and popup submenus are always at the top of the screen and do not collapse automatically. I've tried adding close QCombobox and menu after losing focus, but it doesn't work.
How to solve this problem?
Thanks!QT 5.15.12
MacOS 14.0.0The code is:
MyQComboBox::MyQComboBox(QWidget *parent) : QComboBox(parent)
{
this->setView(new QListView());
this->setStyle(QStyleFactory::create("Windows"));
this->view()->window()->setWindowFlags(Qt::Popup | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint);
this->view()->window()->setAttribute(Qt::WA_TranslucentBackground);
}SkinComboBox = new MyQComboBox();
SkinComboBox->setObjectName("SkinComboBox");
SkinComboBox->addItem(tr("widget.settings.skin.light"));
SkinComboBox->addItem(tr("widget.settings.skin.dark"));Hi @sprkxr
It's an old bug on Mac.
The assertion that Qt doesn't have to care of what happens outside of windows is wrong on mac, because of the presence of the main menu bar on top of the screen.Have a try with Qt6, things have changed in this area.
[EDIT] the bug when switching window/app exists on early version of Qt5, but not on Qt 15 in my experience, only the bug with the main menu bar persists.
I'm using Qt15 with QTCreator compiled with Qt6 and the bug with the main menu bar is corrected.