Results 1 to 2 of 2

Thread: Can't change items aligment in QGraphicsLinearLayout

  1. #1
    Join Date
    Feb 2007
    Location
    Wroclaw, Poland
    Posts
    72
    Thanks
    6
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Can't change items aligment in QGraphicsLinearLayout

    I create one QGraphicsWidget inside which in two columns I want to place circles.
    So inside this widget tree layout are created. One main to store two vertical Layouts.


    Qt Code:
    1. m_hbMainLayout = new QGraphicsLinearLayout(Qt::Horizontal);
    2. vbLeftLayout = new QGraphicsLinearLayout(Qt::Vertical);
    3. vbRightLayout = new QGraphicsLinearLayout(Qt::Vertical);
    4.  
    5. m_hbMainLayout->addItem(vbLeftLayout);
    6. m_hbMainLayout->addItem(vbRightLayout);
    7.  
    8. if (layout())
    9. delete layout();
    10. setLayout(m_hbMainLayout);
    To copy to clipboard, switch view to plain text mode 

    Then I add circles by
    Qt Code:
    1. vbLeftLayout->addItem(devGUIChild);
    2. vbLeftLayout->setAlignment(devGUIChild,Qt::AlignVCenter);
    To copy to clipboard, switch view to plain text mode 

    But at the end circles aren't placed as I expect.


    Those circles should be placed vertically evenly and in the middle. Right ones are placed evenly, but the left one isn't placed in the middle.
    This approach works fine when I work with normal widgets and layout. Could some one tell me how to fix it?
    Last edited by T4ng10r; 22nd December 2009 at 12:47.

  2. #2
    Join Date
    Feb 2007
    Location
    Wroclaw, Poland
    Posts
    72
    Thanks
    6
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Thumbs up Re: Can't change items aligment in QGraphicsLinearLayout

    After few investigations I find out that layout isn't taking his size from widget inside which his placed. Widget size is fixed to (60,120), while layout takes only (20,46) for him self. Two item placed inside are 20,20 in size, so layout takes only so much space to enclose this items.
    Why layout isn't expanding? I set size policy for layout to QSizePolicy::MinimumExpanding, but it didn't help at all.

    When items inside had set only minimum and preferred size (maximum wasn't set) - layout was taking as much space as possible. But items placement wasn't correct. Now when I set maximum size too - layout isn't expanding.

    EDIT:
    I couldn't find any good flexible solution. Even QT examples weren't helpful - in them item were placed by calculating position in paint() method. And this is what I did.
    But, in my opinion. layout should place items spread evenly on entire available space.
    Last edited by T4ng10r; 28th December 2009 at 12:35.

Similar Threads

  1. Replies: 5
    Last Post: 27th November 2009, 13:57
  2. Some menubar items can not be clicked
    By richardander in forum Qt Programming
    Replies: 4
    Last Post: 11th March 2009, 00:26
  3. Use delegate to draw different type of items
    By nifei in forum Qt Programming
    Replies: 1
    Last Post: 19th January 2009, 13:16
  4. Light items for the graphicsView
    By maverick_pol in forum Qt Programming
    Replies: 12
    Last Post: 1st November 2007, 18:51
  5. Selective highlighting of Items
    By Kapil in forum Qt Programming
    Replies: 3
    Last Post: 26th May 2006, 12:20

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.