Results 1 to 5 of 5

Thread: QGridLayout overlapping items

  1. #1
    Join Date
    Oct 2015
    Posts
    17
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default QGridLayout overlapping items

    hi friends.

    i have some items in a QGridLayout that fine horizontally but vertically overlapped.
    when i reduce minimum size of items they are fine but when i increase their size overlapping happens.
    this is my code

    Qt Code:
    1. for number in range(len(items)):
    2. lbl = QLabel()
    3. lbl.setMinimumSize(item_size)
    4. lbl.setContentsMargins(0, 0, 0, 0)
    5. grid_layout.addWidget(lbl, number, 1, 1, 1)
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: QGridLayout overlapping items

    Overlapping what? There is only one row of labels in the grid layout, so i guess you mean it overlaps other widgets on a form. The usual reason would be that your grid layout has not been correctly added to the parent widget's layout.

  3. #3
    Join Date
    Oct 2015
    Posts
    17
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: QGridLayout overlapping items

    i have around 300 labels that they overlapping each other vertically and the for loop that is in my code while loop for 300 times and each time it add a label to it's corresponding row in gridlayout. like this picture


    error.png

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

    Default Re: QGridLayout overlapping items

    Sorry, my bad, there is a single column of widgets.

    The layout is given a fixed vertical space to divide between the widgets in the layout. It does this by resizing the widgets so they fit without overlapping. If you are placing 300 widgets in a fixed vertical space then they generally are allocated very little vertical space each. If you then try to force the individual widgets to be larger than the height the layout has to work with then the layout cannot function normally and something has to give, probably leading to the situation I cannot see in your thumbnail.

    It seems that you expect the parent widget to grow to accommodate the layout content and not the other way around. Is that the case?

  5. #5
    Join Date
    Oct 2015
    Posts
    17
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: QGridLayout overlapping items

    i did not think layout have a fixed space.
    when number of items is less (around 100) overlapping not happens but when number of items increases overlapping happening

    this picture is normal situation (100 items)
    ewb-3.jpg

    in the case of 300 items or more top of next item overlapping bottom of previous item

Similar Threads

  1. Replies: 2
    Last Post: 29th October 2010, 10:44
  2. QGridLayout: how to know it has finished rendering items?
    By slash_blog in forum Qt Programming
    Replies: 0
    Last Post: 8th June 2010, 13:06
  3. Delete a QGridLayout and New QGridLayout at runtime
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 5th November 2007, 14:01
  4. QGraphicsView overlapping items
    By juliarg in forum Newbie
    Replies: 1
    Last Post: 5th April 2007, 10:35
  5. overlapping canvases
    By quickNitin in forum Newbie
    Replies: 11
    Last Post: 8th October 2006, 12:22

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.