Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to always show my qt widget on top of my parent window but also on top of parent's child widgets?
Basically I have a qt widget where I always want it visible on top of everything in the parent window, including other child widgets of the parent window. My widget doesn't have any children.
My widget is not modal and it should not block any input.
Lastly I don't want it to be on top of unrelated apps/windows, that's why I can't use WindowStaysOnTopHint, because that makes my widget show up on top of every thing which is not what I want.
Thanks a lot in advance.
after you call show() on your widget, call also raise() on it, it will push it on the top
Thanks, I just tried it, but just doing mywidget.raise() raises syntax error so I did it using getattr, then call this function, but after that another child window that was below my widget, when it gets focus goes over my widget, because this widget encompasses mine and others and it has to.
JonB last edited by
Thanks, I just tried it, but just doing mywidget.raise() raises syntax error
raise()is a method of
QWidget(https://doc.qt.io/qt-5/qwidget.html#raise) you have done something wrong if you get a syntax error.
lachdanan last edited by lachdanan
@JonB no it's because raise is also a reserved keyword in Python so I can't use it as an instance method, that's why I invoked in dynamically.
Anyway this technique didn't work for me as I mentioned above.
JonB last edited by JonB
no it's because raise is also a reserved keyword in Python so I can't use it as an instance method, that's why I invoked in dynamically.
It always helps if you get a syntax error if you say you are using Python and not C++.... So did you see e.g. https://doc.qt.io/qtforpython/PySide2/QtWidgets/QWidget.html#PySide2.QtWidgets.PySide2.QtWidgets.QWidget.raise_ or similarly if you are PyQt? That's why they made it
@JonB thx a lot you are right I should have mentioned Python but it will be the same as dynamically calling it. I will give it a try when I go home.
Here the last reply basically explains the issue I had with raise:
There is a much larger child widget that goes in front of mine when it receives focus. This widget is where you do most of the work so it's normal.
Mine is supposed to be a monitor you just look at from time to time like cpu monitor. I just want it to always be on top of this app.