Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Problems moving widgets inside the layout

    General and Desktop
    1
    1
    759
    Loading More Posts
    • 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.
    • J
      jeanrl last edited by

      Must do exactly as is done in designer mode, move widgets within the layout and other widgets automatically realign, example:

      I have 4 widgets and want to get 3 and move the mouse to one above the 1st position, then he should be the first and realign the rest, I'm just not getting it.

      My mouseMoveEvent method is as follows:
      (I'm using QPushButton, but it is only for testing)

      @
      void Widget :: mouseMoveEvent (QMouseEvent * event)
      {
           event-> accept ();

      if (event-> buttons () & Qt :: LeftButton)
           {
              posMove = event-> pos ();
              ui-> pushButton-> move (QPoint (posMove.x (), (posMove.y ())));
              qDebug () << posMove;

      }
      }
      @

      And my mouseRelease method is as follows:
      (I'm using a specific test for QPushButton too, but I have to know which widget the mouse is dragging and yet also know how to do this)

      @
      void Widget :: mouseReleaseEvent (QMouseEvent * event)
      {
           ui-> pushButton-> setVisible (false);

      ui-> pushButton-> setGeometry (posMove.x (), posMove.y (), ui-> pushButton-> width (), ui-> pushButton-> height ());

      ui-> pushButton-> setVisible (true);
      }
      @

      Very grateful for the attention.

      Hugs.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post