Results 1 to 7 of 7

Thread: QGraphicsLayout - same widths and heights for all cells, two items in the same cell

  1. #1
    Join Date
    Jan 2009
    Location
    Czech Republic
    Posts
    26
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QGraphicsLayout - same widths and heights for all cells, two items in the same cell

    Hi. I got a class sub-classing QGraphicsSvgItem and QGraphicsLayoutItem so it should be possible to add this item to QGraphicsLayout, right?
    Now, I trying to figure how to create a grid layout where the cells are stretching (like in normal QGridLayout or QGraphicsGridLayout) but but all cells are squares. I would take the widest column or highest row and resize all rows and columns accordingly. Would that be somehow possible? If yes, how? I thought I would just subclass QGraphicsGridLayout and during each resize I would find the widest column or highest row and adjust width and height of the remaining columns and rows. However I did not find a way to get the actual width or height of the column or row respectively.
    Another thing I would like to achieve with this layout is possibility to place more items into one cell - would that be somehow possible? If yes, how (briefly)? Or how would you imitate it. Again, I thought I would subclass QGraphicsItem create two QGraphicsGridLayouts as members (since I will only require 2 items at max on top of each other) do the resizing as I said in the first paragraph and than place the two layouts on top of each other (if possible) which should imitate the look of two overlapping items.
    Thanks in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QGraphicsLayout - same widths and heights for all cells, two items in the same ce

    Some hints:

    Two items in one cell is not possible but you can nest layouts.

  3. #3
    Join Date
    Jan 2009
    Location
    Czech Republic
    Posts
    26
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsLayout - same widths and heights for all cells, two items in the same ce

    Well, I do not want the width to be fixed, I want it to stretch.
    This is how normal QGraphicsGridLayout would look like

    And this is how my layout would look like in this case - it would of course change if the view was resized.


    I will look into nesting layouts and see if it could help me, thank you
    Edit: I'm not sure if I got "nested layouts" right but does not that mean that I just put one layout into another's cell? If so, than thats is probably not what I could use here. :/
    Attached Images Attached Images

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QGraphicsLayout - same widths and heights for all cells, two items in the same ce

    Well as I understand you you want a "fix" layout till a cell changes its size. If you get notice of a geometry change, reset the "fix" size or only set the minimum size to get grid with same cell boundings.

    May be you provide a fast image mocup what you understand by "to place more items into one cell". Because if you put more items in one cell you have to lay them out => use a layout. And then you have a layout in a layout => nested layout.

  5. #5
    Join Date
    Jan 2009
    Location
    Czech Republic
    Posts
    26
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsLayout - same widths and heights for all cells, two items in the same ce

    Yeah, I could do that with fix size... but, how do I get the widths of the columns or rows to determine which one is the widest?
    Here is the image mockup

    This is how my grid layout with 2 columns and 1 row would look like.
    There are 3 items total inside
    1. Blue square with yellow borders in 0, 0
    2. Blue square with yellow borders in 1, 0
    3. Green circle in 0, 0 - as you can see it's not above the square nor below, etc. it's overlapping the square.
    Attached Images Attached Images

  6. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QGraphicsLayout - same widths and heights for all cells, two items in the same ce

    Quote Originally Posted by Palmik View Post
    Yeah, I could do that with fix size... but, how do I get the widths of the columns or rows to determine which one is the widest?
    QGraphicsGridLayout::itemAt() => QGraphicsLayoutItem::geometry()
    Here is the image mockup

    This is how my grid layout with 2 columns and 1 row would look like.
    There are 3 items total inside
    1. Blue square with yellow borders in 0, 0
    2. Blue square with yellow borders in 1, 0
    3. Green circle in 0, 0 - as you can see it's not above the square nor below, etc. it's overlapping the square.
    Ah, you are talking about graphic items not layout items... So there is no problem: arrange the three items in a QGraphicsItemGroup, then they behave like one item.

  7. The following user says thank you to Lykurg for this useful post:

    Palmik (16th February 2010)

  8. #7
    Join Date
    Jan 2009
    Location
    Czech Republic
    Posts
    26
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsLayout - same widths and heights for all cells, two items in the same ce

    You are right, that should do it


    Quote Originally Posted by Lykurg View Post
    Ah, you are talking about graphic items not layout items... So there is no problem: arrange the three items in a QGraphicsItemGroup, then they behave like one item.
    This should work
    I have one more and hopefully last question. If I create QGraphicsItemGroup of 2 items which are inheriting both from QGraphicsSvgItem and QGraphicsLayoutItem (which should give it the capabily to be added to QGraphicsLayouts) I will have to reimplement the QGraphicsItemGroup so that it inherits from QGraphicsLayoutItem as well to be able to add it to QGraphicsLayout, would not I (not that it would much of a problem... but still )?
    Last edited by Palmik; 16th February 2010 at 18:29.

Similar Threads

  1. Forcing equal row heights in QTableWidget
    By wssddc in forum Newbie
    Replies: 2
    Last Post: 2nd November 2009, 01:16
  2. QGraphicsLayout::geometry()
    By isutruk in forum Qt Programming
    Replies: 1
    Last Post: 19th October 2009, 15:43
  3. Extending QGraphicsLayout
    By Darkman in forum Qt Programming
    Replies: 0
    Last Post: 13th March 2009, 12:09
  4. auto resizing column/row widths
    By raman_31181 in forum Qt Programming
    Replies: 2
    Last Post: 11th September 2008, 18:16
  5. QTableView row heights
    By Brandybuck in forum Qt Programming
    Replies: 8
    Last Post: 7th November 2006, 03:08

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.