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. Method raise() of class QWidget does not work as expected
Forum Updated to NodeBB v4.3 + New Features

Method raise() of class QWidget does not work as expected

Scheduled Pinned Locked Moved General and Desktop
15 Posts 3 Posters 10.3k Views 1 Watching
  • 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.
  • R Offline
    R Offline
    Ruu_Rinki
    wrote on last edited by
    #3

    Rahul, set the window size is not a good idea, I would like to return the window in the same condition in which it was.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #4

      Did you try "QWidget::showNormal":http://doc.qt.nokia.com/4.7/qwidget.html#showNormal ?

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Rahul Das
        wrote on last edited by
        #5

        in the docs
        " On X11, the result depends on the Window Manager "
        also
        " Note that the window must be visible, otherwise activateWindow() has no effect. "


        Declaration of (Platform) independence.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Ruu_Rinki
          wrote on last edited by
          #6

          Gerolf, yes, i'm try it :)

          1 Reply Last reply
          0
          • R Offline
            R Offline
            Ruu_Rinki
            wrote on last edited by
            #7

            Rahul, i now that result depends on the Window Manager, so I wanted to know about the raise () for kde4. Because, this metod should perform the necessary role of I.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #8

              raise() brings the window to the top but does not change the size. So if you have a window that is in maximze or normal state and call raise(), it could come to front, but if it is minimized, it will not.

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • R Offline
                R Offline
                Ruu_Rinki
                wrote on last edited by
                #9

                Gerolf, you are right, but this method ( raise() ) does not work as written in the documentation. This is not come window to front.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  giesbert
                  wrote on last edited by
                  #10

                  If the window comes to the front (if it is not minimized) is depending on the OS. On windows for example, raise does not work if your process does not own the input focus. This is done by MS win to ensure, not all windows can raise themselfe in front. Same applies to the input focus (activate).

                  Nokia Certified Qt Specialist.
                  Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    Ruu_Rinki
                    wrote on last edited by
                    #11

                    Gerolf, we assume that raise() does not work, then you might know how to activate a window in another way? I'm doing now:
                    setWindowState(Qt::WindowStates(Qt::WindowActive));

                    In this case, the minimized window turns and rises above all other windows, but the focus on him is not translated. However, if the window is inactive and is behind other windows, then neither it nor the focus is not transferred to the top.
                    Do you know something about this?

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      Ruu_Rinki
                      wrote on last edited by
                      #12

                      Gerolf, my question relates only to KDE and Mandriva Linux

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        giesbert
                        wrote on last edited by
                        #13

                        I have seen that you are talking on linux, but I assume that in case of focus handling etc, they are not too much different.

                        Calling activateWindow() (on windows I know) will also not get the focus, if the input focus is on a different application. This is against the windows policies, don't know exactly how it is on Linux X11. As stated in the docs, it depends on the window manager, so you can't rely on it to get the input focus (as you don't know which window manager your users will use).

                        bq. raise():
                        Raises this widget to the top of the parent widget's stack.
                        After this call the widget will be visually in front of any overlapping sibling widgets.

                        bq. activateWindow():
                        This function performs the same operation as clicking the mouse on the title bar of a top-level window. On X11, the result depends on the Window Manager. If you want to ensure that the window is stacked on top as well you should also call raise(). Note that the window must be visible, otherwise activateWindow() has no effect.
                        On Windows, if you are calling this when the application is not currently the active one then it will not make it the active window. It will change the color of the taskbar entry to indicate that the window has changed in some way. This is because Microsoft does not allow an application to interrupt what the user is currently doing in another application.

                        IMHO forcing an application to give the focus to anotherone is not a good style. Those are things I hat on applications.

                        Nokia Certified Qt Specialist.
                        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                        1 Reply Last reply
                        0
                        • R Offline
                          R Offline
                          Ruu_Rinki
                          wrote on last edited by
                          #14

                          Gerolf, Thank you for such a detailed response. But it is necessary for me.
                          Ok, May I offer you friendship? ^^

                          1 Reply Last reply
                          0
                          • G Offline
                            G Offline
                            giesbert
                            wrote on last edited by
                            #15

                            [quote author="Ruu_Rinki" date="1315400091"]Gerolf, Thank you for such a detailed response. But it is necessary for me.[/quote]

                            We had the same problems in our project (but on windows) ;-) We have a singleton application which should üpop up if someone starts a second instance...

                            What we did is, we forced our window to the top (set top level falg, remove it, via windows API), the only thing that does not work is setting the focus .... Not nice but better than nothing ...

                            Nokia Certified Qt Specialist.
                            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                            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