Workaround Qt bug Combobox dropdown appear behind window - qt

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. 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
Is there a workaround for this? I am using Qt 5.9.1.
EDIT: Add some code:
This in MainWindow constructor:
Qt::WindowFlags flags = this->windowFlags();
this->setWindowFlags(flags|Qt::WindowStaysOnTopHint);
Then I put a QComboBox in the mainwindow with preloaded items. 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.
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. It only update certain things like Qt Creator.
I needed to choose "Add or remove Components" and then adding Qt 5.10.1, but only check the MinGW 32bit only. (Uncheck all others otherwise you need them (like android or other)).
Even after that, you also need to manually download CMake (get it from cmake.com) and set it in "Manage Kits" in Qt Creator.

Related

combobox qml in QT stay down

I add simple combobox in my qml form but after selection, the button of it stay blue like the mouse stay clicked and I can not select any more after the first click, do you know why?...
ComboBox{
model:["test1","test2"]
}
image upload is not working then here drive link to see what I mean:
https://drive.google.com/open?id=1Un0pOCTbmEu_FeCHDzTYKF8FbV4YTxHR
thank you for your help
Qt 5.10.0 added support for native menus on Windows. This caused a regression in Qt Quick Controls 1 ComboBox. ComboBox did not get notified that the menu popup was closed, so it thought it was still pressed and therefore refused to re-open the popup. The bug (QTBUG-64628) has been fixed in Qt 5.10.1. Try updating.

Qt Creator Debugger Views become Disabled

While debugging in Qt Creator (ver 3.4.2), if I hit the escape key (which I tend to do often to declutter my work space), then all of the debugger views including the debugger toolbar become hidden (as expected), but later I can't get them back. If I go under Qt Creator's main menu->Window, then Views is disabled.
Here's an example of a basic window before I click the escape key. Notice I have all of the debugging views showing (i.e. Breakpoints, Stack, Locals and Expressions, etc...)
Here's an example of my window after I've clicked the escape key. Notice how all of the debugging windows are hidden (as expected). My question is, now how do I get the windows back? You can see how the "Views" submenu under the "Window" menu is disabled.
Is there some sort of "Show Debugger Toolbar" keyboard shortcut? Or is there another menu somewhere to get this back? Any help would be much appreciated.
Under the Window menu, enable Show Mode Selector. This will show a strip down the left of your window where you should see a Debug tab you can click on to put Qt Creator back in Debug mode.

Qt creator - make a dynamic interface

I am working on a small UI with QT Creator and its drag-n'-drop tool (QT Designer). Everything was fine till I realized I had to make some widgets dynamic. For example, I have a checkbox and I want some button to appear only if this checkbox is checked by the user or I would like to change the appearance of another widget when the user clicks on some button.
Is it possible to do it only with QT Designer?
Yes, but it's very limited.
Qt designer have signal&slot editor. Yes, you can connect signal clicked(bool) to setVisible(bool) slot on button and make button visible only when checkbox is checked (see screenshot).
But when You need more complex dynamic interface (e.g. creating buttons), designed will not help You.

how to se t the right click operations of a link in qtwebkit

How to edit QtWebKit's right-click context menu in Qt Creator?
how to get response in QtWebKit
https://qt-project.org/forums/viewthread/15149/
i have seen all these threads and more but cant get my anwser
i want to set the righ click menu of links images frames etc. in qtwebkit
in qwebview
i have heard that we have to install an event filter and get the object which is at that position but i am not geting it
can you tell me a simple and sweet solution
tell how to set the operation of that action
also iut would be great if you can give a sample live working code
i have heard that we have to use QMenu and QAction for this.
To get a "standard" menu from QWebView based upon where you clicked, do:
page()->updatePositionDependentActions(pos);
QMenu* ctxMenu = page()->createStandardContextMenu();
to know on what you clicked, use
QWebHitTestResult hit = page()->mainFrame()->hitTestContent(pressPoint.toPoint());

Getting errors when using Qt Creator to create signals and slots

I've created a new dialog using Qt Creator (version 4.7.0) - one of the templated forms (with an OK and a Cancel button).
I want the user to enter some data on the form and then when they click OK, it saves that information. So I had a look, and saw that when the OK button is clicked, it sends and signal to the dialog's accept slot.
So I right clicked on the dialog in the design view, and selected "Go to slot...". I clicked on the "accepted" option, which dropped an on_Dialog_accepted() method into the dialogs class. However, when I run the program and open the dialog, I get an error in my console saying QMetaObject::connectSlotsByName: No matching signal for on_Dialog_accepted()
So what did I do wrong?
I've found documentation on the connectSlotsByName - but nothing about any obvious pratfalls that an inexperienced Qt-developer can get themselves into.
Right-clicking on the dialog in the design view prior to selecting "Go to slot..." made a connection from the dialog's signals to the dialog's slot, which doesn't work with QMetaObject::connectSlotsByName(), since that method searches for all child objects, but not for the object itself.
What you wanted to do actually is right-clicking on the OK button, then selecting "Go to slot..." from there. It will then create a slot with the name of your button widget, and the connection will be made correctly at run-time.
It makes no sense that QtDesigner lets you select "Go to slot..." from the Dialog. You might want to file a bug to Qt's devs for that.
It is basically just as Fred explained: you did not do anything wrong. This is a QtCreator bug. And a pretty old one for that matter. Unfortunately, even two years later nothing in that regard has changed.
The assignee of the aforementioned bug decided to sort of redirect it to this QtCore bug, which simply asks for QMetaObject::connectSlotsByName() to be changed in a way that it also processes the passed object and not only its children (thereby fixing the QtCreator issue).
I had a look at the source and submitted a trivial patch.
Update: The patch got accepted, meaning this bug is going to be fixed in Qt 5.1. Note: it is not relevant which version of QtCreator your are using but which version of Qt you link your code to.

Resources