How to always show my qt widget on top of my parent window but also on top of parent's child widgets?
-
Hi,
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.
Any ideas?
Thanks a lot in advance.
-
Hi,
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.
Any ideas?
Thanks a lot in advance.
@lachdanan
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.
-
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.
@lachdanan said in How to always show my qt widget on top of my parent window but also on top of parent's child widgets?:
Thanks, I just tried it, but just doing mywidget.raise() raises syntax error
Since
raise()
is a method ofQWidget
(https://doc.qt.io/qt-5/qwidget.html#raise) you have done something wrong if you get a syntax error. -
@lachdanan said in How to always show my qt widget on top of my parent window but also on top of parent's child widgets?:
Thanks, I just tried it, but just doing mywidget.raise() raises syntax error
Since
raise()
is a method ofQWidget
(https://doc.qt.io/qt-5/qwidget.html#raise) you have done something wrong if you get a syntax error. -
@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.
@lachdanan said in How to always show my qt widget on top of my parent window but also on top of parent's child widgets?:
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
raise_()
for Python.... -
@lachdanan said in How to always show my qt widget on top of my parent window but also on top of parent's child widgets?:
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
raise_()
for Python....@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:
https://stackoverflow.com/questions/2463125/keep-widget-on-top-in-qtThere 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.