Problems moving widgets inside the layout



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.