Results 1 to 7 of 7

Thread: How to arrange the buttons in a layout after deletion of one or two from the middle

  1. #1
    Join Date
    Jul 2013
    Posts
    25
    Qt products
    Qt5
    Platforms
    Windows

    Default How to arrange the buttons in a layout after deletion of one or two from the middle

    I want to maintain a gridlayout.While adding buttons,it should be in the row by column manner and when we delete any item, the remaining items should be rearranged to maintain the currect layout.
    can u suggest any method to neatly arrange the buttons.
    Thanks in advance.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: How to arrange the buttons in a layout after deletion of one or two from the midd

    What do you mean by "currect layout" or "neatly arrange"? Items in a grid layout stay in the cell you put them in. If you remove widgets from cells the row/column height/width is driven by the items remaining in that row/column.

  3. #3
    Join Date
    Jul 2013
    Posts
    25
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to arrange the buttons in a layout after deletion of one or two from the midd

    Thank you for your response.By correctly or neatly I mean that while deleting any button from the middle,after deletion there should not be a gap between the remaining buttons.
    If it is a 4*4 grid layout,and it contains 16 buttons. when I delete a button from the position (1,2) , then the button from the position(1,3) shold be moved to the position(1,2) and button(1,4) to (1,3) and so on. The last position should be empty, and i can add new buttons to that position.
    All your suggestions are appreciable.
    Thanks in advance.

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 334 Times in 317 Posts

    Default Re: How to arrange the buttons in a layout after deletion of one or two from the midd

    That exactly isnt a grid layout what you want. In grid layout, you specify rows and columns for the cells.

    What you want is a flowlayout with the items having a particular size. Search for flowlayout in Qt.

  5. #5
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    8
    Thanked 133 Times in 128 Posts

    Default Re: How to arrange the buttons in a layout after deletion of one or two from the midd

    keep your buttons in a QList<QPushButton*>, whenever a button is deleted, remove it from the list. Now iterate over the list and add every button in the grid layout again.

  6. #6
    Join Date
    Jul 2013
    Posts
    25
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to arrange the buttons in a layout after deletion of one or two from the midd

    how can I get the current row and column of the grid layout????

  7. #7
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    8
    Thanked 133 Times in 128 Posts

    Default Re: How to arrange the buttons in a layout after deletion of one or two from the midd

    do simple math. check the index of deleted button in list, 2nd is in cell (0,2)

Similar Threads

  1. Grid Layout -- and buttons spacing
    By Noob in forum Newbie
    Replies: 4
    Last Post: 6th May 2013, 08:30
  2. Arrange Widgets in QSplitter
    By vinodpaul in forum Newbie
    Replies: 3
    Last Post: 7th September 2012, 11:17
  3. Replies: 1
    Last Post: 14th July 2012, 09:59
  4. Resizing buttons in Layout
    By "BumbleBee" in forum Newbie
    Replies: 9
    Last Post: 26th March 2011, 06:28
  5. How to arrange panes
    By Asperamanca in forum Qt Tools
    Replies: 3
    Last Post: 23rd October 2009, 09:50

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.