2 Attachment(s)
QT5 + Qt::WindowStaysOnTopHint + QComboBox strange problem
Hi,
I have one quite strange problem with AlwaysOnTop window, system - Qt5.9.1, Win10 x64, MSVC2017 x64 app.
Let's imagine simple aplication with QMainWindow that contains only one QComboBox. When I set to windows flags Qt::WindowStaysOnTopHint after ui->setupUi(this) in constructor then application window after start and unfold combobox list is like:
Attachment 12609,
but when I switch to another window(s) and back, and again unfold combobox list, then is look like this:
Attachment 12610
Simply - listbox is hidden behind main form partially or whole depends on its size.
It is not tied on one special machine , I reproduced it on two independent Win10 x64 Pro computers.
If form is not always-on-top, then everything works OK.
Code in main dialog window:
Code:
#include "mainwindowdialog.h"
#include "ui_mainwindowdialog.h"
MainWindowDialog
::MainWindowDialog(QWidget *parent
) : QMainWindow(parent
), ui
(new Ui
::MainWindowDialog){
ui->setupUi(this);
ui->comboBox->clear();
<<
QApplication::translate("MainWindowDialog",
"New Item 1", Q_NULLPTR
) <<
QApplication::translate("MainWindowDialog",
"New Item 2", Q_NULLPTR
) <<
QApplication::translate("MainWindowDialog",
"New Item 3", Q_NULLPTR
) <<
QApplication::translate("MainWindowDialog",
"New Item 4", Q_NULLPTR
) <<
QApplication::translate("MainWindowDialog",
"New Item 5", Q_NULLPTR
) <<
QApplication::translate("MainWindowDialog",
"New Item 6", Q_NULLPTR
) <<
QApplication::translate("MainWindowDialog",
"New Item 7", Q_NULLPTR
) <<
QApplication::translate("MainWindowDialog",
"New Item 8", Q_NULLPTR
) <<
QApplication::translate("MainWindowDialog",
"New Item 9", Q_NULLPTR
) <<
QApplication::translate("MainWindowDialog",
"New Item 10", Q_NULLPTR
) <<
QApplication::translate("MainWindowDialog",
"New Item 11", Q_NULLPTR
) <<
QApplication::translate("MainWindowDialog",
"New Item 12", Q_NULLPTR
) <<
QApplication::translate("MainWindowDialog",
"New Item 13", Q_NULLPTR
) <<
QApplication::translate("MainWindowDialog",
"New Item 14", Q_NULLPTR
));
this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint);
}
MainWindowDialog::~MainWindowDialog()
{
delete ui;
}
Header:
Code:
#ifndef MAINWINDOWDIALOG_H
#define MAINWINDOWDIALOG_H
#include <QMainWindow>
#include "QComboBox.h"
namespace Ui {
class MainWindowDialog;
}
{
Q_OBJECT
public:
explicit MainWindowDialog
(QWidget *parent
= 0);
~MainWindowDialog();
private:
Ui::MainWindowDialog *ui;
};
#endif // MAINWINDOWDIALOG_H
When I unfold listbox of combobox first time it look like:
1. appears listbox
2. part of main form is redrawn over listbox
3. listbox is redrawn again over form,
but after switching to another window and back the third step is omitted. so it stays in state like the second picture.
What is the reason or is any available solution please to this strange behavior - it does the same in quite complex application, where listboxes of comboboxes are completely hidden.
Many thanks for any helpful idea...
Regards,
dwarfik.
Re: QT5 + Qt::WindowStaysOnTopHint + QComboBox strange problem
There is bug reported about that, which has been fixed in version 5.9.2.
https://bugreports.qt.io/browse/QTBUG-63787
Hope it helps!