Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to always show my qt widget on top of my parent window but also on top of parent's child widgets?
QtWS25 Last Chance

How to always show my qt widget on top of my parent window but also on top of parent's child widgets?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 5.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lachdanan
    wrote on last edited by
    #1

    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.

    J.HilkJ 1 Reply Last reply
    0
    • L lachdanan

      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.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @lachdanan
      after you call show() on your widget, call also raise() on it, it will push it on the top


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      1
      • L Offline
        L Offline
        lachdanan
        wrote on last edited by
        #3

        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.

        JonBJ 1 Reply Last reply
        0
        • L lachdanan

          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.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @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 of QWidget (https://doc.qt.io/qt-5/qwidget.html#raise) you have done something wrong if you get a syntax error.

          L 1 Reply Last reply
          0
          • JonBJ JonB

            @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 of QWidget (https://doc.qt.io/qt-5/qwidget.html#raise) you have done something wrong if you get a syntax error.

            L Offline
            L Offline
            lachdanan
            wrote on last edited by lachdanan
            #5

            @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.

            JonBJ 1 Reply Last reply
            0
            • L 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.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @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....

              L 1 Reply Last reply
              3
              • JonBJ JonB

                @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....

                L Offline
                L Offline
                lachdanan
                wrote on last edited by
                #7

                @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-qt

                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.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved