Results 1 to 8 of 8

Thread: Grid layout

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Grid layout

    So you have a widget which contains icons, which are also widgets right? Sure you can move the icon widgets to a fixed position if you want to.
    You will have to calculate the corner/edge positions yourself, though. At least QRect contains several handy methods that.
    J-P Nurmi

  2. #2
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Grid layout

    Quote Originally Posted by jpn
    So you have a widget which contains icons, which are also widgets right? Sure you can move the icon widgets to a fixed position if you want to.
    You will have to calculate the corner/edge positions yourself, though. At least QRect contains several handy methods that.
    Do i absolutely need to use QRect for this? How could I do it using Qrect...could you give me an example?

    Thanks

    Nupul

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Grid layout

    Quote Originally Posted by nupul
    Do i absolutely need to use QRect for this?
    Heh, you absolutely don't have to use, I only mentioned I find QRect handy for this kind of calculations..

    Quote Originally Posted by nupul
    How could I do it using Qrect...could you give me an example?
    Qt Code:
    1. // geometries
    2. QRect areaRect = areaWidget->geometry(); // the whole "area"
    3. QRect topRightRect = topRightWidget->geometry(); // the "icon" in the top right corner
    4. QRect middleLeftRect = middleLeftWidget->geometry(); // the "icon" in the middle left edge
    5.  
    6. // top right corner
    7. topRightRect.moveTopRight(areaRect.topRight()); // align to top right corner
    8. topRightWidget->setGeometry(topRightRect); // move the icon widget
    9.  
    10. // middle left edge
    11. middleLeftRect.moveCenter(areaRect.center()); // centralize
    12. middleLeftRect.moveLeft(areaRect.left()); // align to left edge
    13. middleLeftWidget->setGeometry(middleLeftRect); // move the icon widget
    To copy to clipboard, switch view to plain text mode 
    As you can see, with QRect it's simple to align items to corners/edges.
    J-P Nurmi

  4. The following user says thank you to jpn for this useful post:

    nupul (22nd April 2006)

Similar Threads

  1. qdirmodel in grid layout
    By babu198649 in forum Newbie
    Replies: 1
    Last Post: 27th July 2008, 08:26
  2. How do I layout in a Grid?
    By DPinLV in forum Qt Tools
    Replies: 7
    Last Post: 10th August 2006, 01:37
  3. Dynamic grid layout
    By eriwik in forum Qt Programming
    Replies: 1
    Last Post: 12th June 2006, 15:19
  4. How do I move a widget inside a grid Layout
    By barnabyr in forum Newbie
    Replies: 1
    Last Post: 8th May 2006, 23:23
  5. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45

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.