简体   繁体   English

解决方法Qt bug Combobox下拉菜单显示在窗口后面

[英]Workaround Qt bug Combobox dropdown appear behind window

Right now I have a small tool app that runs in the icon tray. 现在,我有一个运行在图标托盘中的小型工具应用程序。 When I click on the icon, the app goes into "windowstayontophint" mode. 当我单击该图标时,该应用程序进入“ windowstayontophint”模式。 I added a Combo Box on this window. 我在此窗口上添加了一个组合框。 But when I click elsewhere on desktop, and then click the combo box, the drop down window goes to the back of the window. 但是,当我单击桌面上的其他位置,然后单击组合框时,下拉窗口将转到窗口的背面。 This seems to be a known bug as reported here: 这似乎是一个已知的错误,如下所示:

https://bugreports.qt.io/browse/QTBUG-61804 https://bugreports.qt.io/browse/QTBUG-61804

Is there a workaround for this? 有没有解决方法? I am using Qt 5.9.1. 我正在使用Qt 5.9.1。

EDIT: Add some code: 编辑:添加一些代码:

This in MainWindow constructor: 这在MainWindow构造函数中:

Qt::WindowFlags flags = this->windowFlags();
this->setWindowFlags(flags|Qt::WindowStaysOnTopHint);

Then I put a QComboBox in the mainwindow with preloaded items. 然后,我将一个带有预加载项的QComboBox放入主窗口。 First time click, the dropdown appears on top as normal. 第一次单击时,下拉菜单将正常显示在顶部。 Then I click onn desktop and then back on the mainwindow and combobox. 然后,我单击桌面,然后回到主窗口和组合框。 And drop down becomes at the back of mainwindow. 下拉菜单位于主窗口的后面。 CLick on the link above to see what I mean. 单击上面的链接以了解我的意思。 The bug report also provide screenshot of what is happening. 错误报告还提供了正在发生的情况的屏幕截图。

Nobody want to put an answer, so I answer this myself. 没人想回答,所以我自己回答。

ANSWER: Update to latest Qt. 解答:更新到最新的Qt。

It did not work for me because I was having trouble updating (noob here). 它对我不起作用,因为我无法进行更新(这里是菜鸟)。 What basically happened was that Selecting "Update" option on Maintenance Tool does not update SDK from 5.9.1 to 5.10.1. 基本上发生的是,在维护工具上选择“更新”选项不会将SDK从5.9.1更新到5.10.1。 It only update certain things like Qt Creator. 它只会更新某些东西,例如Qt Creator。

I needed to choose "Add or remove Components" and then adding Qt 5.10.1, but only check the MinGW 32bit only. 我需要选择“添加或删除组件”,然后添加Qt 5.10.1,但仅检查MinGW 32位。 (Uncheck all others otherwise you need them (like android or other)). (取消选中所有其他选项,否则需要它们(例如android或其他))。

Even after that, you also need to manually download CMake (get it from cmake.com) and set it in "Manage Kits" in Qt Creator. 即使在那之后,您还需要手动下载CMake(从cmake.com获取)并在Qt Creator的“管理工具”中进行设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM