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. Problems moving widgets inside the layout
QtWS25 Last Chance

Problems moving widgets inside the layout

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 807 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.
  • J Offline
    J Offline
    jeanrl
    wrote on last edited by
    #1

    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
    0

    • Login

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