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. QWidget form "sticked" on the left of QMainWindow. is possible?
QtWS25 Last Chance

QWidget form "sticked" on the left of QMainWindow. is possible?

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 1.5k 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.
  • G Offline
    G Offline
    Goranjeb
    wrote on last edited by
    #1

    Hello,
    i'm developing a UI with Qt4.8 and i have a little trouble with it:
    i've created a QMainWindow with many QPushButton inside a QGridLayout. When the user press one of this buttons, a QWidget Form is shown on the left of QMainWindow. When the user try to move the main window, i want that the position of QWidget Form (if it is visible) change according to the new position of the main window. The result is that the QWidget Form seems sticked on the left of QMainWindow. It is possible to set a "property" to do that?

    I also try to intercept the mousePressEvent of title bar but i know that the titlebar of QMainWindow is property of OS and so all the events is managed by the OS. So there is a way to handle this events by my code, without creating QMainWindow with FrameLess property and add a custom TitleBar to handle events inside it? Thanks a lot for all answers.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Do you mean something like a QDockWidget or a floating window ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • G Offline
        G Offline
        Goranjeb
        wrote on last edited by
        #3

        Thanks for your answer. My case is different than QDockWidget.
        I've created two different forms: one is QMainWindow that is visible on launch; the second is shown when a button on QMainWindow is pressed. The second form is outside QMainWindow and has his titlebar etc.

        So, when the user push this button, i want the second form to be "attached" on the left of QMainWindow (outside the mainwindow), and if the user move the QMainWindow, i want the second form to remain "attached" to QMainWindow and move according to the new position of mainwindow.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You could use the moveEvent of your QMainWindow and update the geometry of your second widget to follow that main window.

          Hope it helps

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andreyc
            wrote on last edited by
            #5

            I think "Qmmp":http://qt-apps.org/content/show.php/Qmmp?content=59218 does something similar with its windows.
            Take a look on their sources

            1 Reply Last reply
            0
            • G Offline
              G Offline
              Goranjeb
              wrote on last edited by
              #6

              [quote author="SGaist" date="1409957818"]You could use the moveEvent of your QMainWindow and update the geometry of your second widget to follow that main window.

              Hope it helps[/quote]

              I've already tried to reimplement the moveEvent of QMainWindow, but when the widget receives this event it is already at the new position: so, if i try to change the position of the second form, the result effect is very bad!

              [quote author="andreyc" date="1409985186"]I think "Qmmp":http://qt-apps.org/content/show.php/Qmmp?content=59218 does something similar with its windows.
              Take a look on their sources[/quote]

              I'll take a look, thanks very much!

              1 Reply Last reply
              0
              • G Offline
                G Offline
                Goranjeb
                wrote on last edited by
                #7

                i decide to implement a custom TitleBar in QMainWindow, for manually handle the events of close,minimize and move. This way allow me to receive the onMousePress, onMouseRelease and onMouseMove on the titleBar, and so i can modify the position of the second form in every moment.

                But when i press the minimize button on QMainWindow, the window is hiding and it's shown in the tray: if i click in the icon on tray, the window doesn't go on top. What is the signal that i have to connect to do this?
                I try to reimplement showEvent of QMainWindow with no positive result.
                Thanks a lot for all answers

                EDIT: i use this tutorial to implement the custom title bar: "guide":http://qt-project.org/faq/answer/how_can_i_handle_events_in_the_titlebar_and_change_its_color_etc

                EDIT 2: i found the mistake: i had connect the SIGNAL clicked() of the button for minimization with the hide() SLOT instead showMinimized().

                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