Results 1 to 8 of 8

Thread: Grid layout

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

    Lightbulb Can I achieve this with a Grid layout?!?!?

    can i use a gridlayout on qlistview in a manner such that I am able to place icons on the 4 corners and the midpoints along the 4 borders of the screen/listview?


    i.e

    icon------------icon--------------icon
    |-------------------------------------|
    |-------------------------------------|
    |-------------------------------------|
    |-------------------------------------|
    icon------------------------------ icon
    |-------------------------------------|
    |-------------------------------------|
    |-------------------------------------|
    icon------------icon--------------icon


    Thanks

    Nupul
    Last edited by nupul; 17th April 2006 at 12:28.

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

    Default Re: Grid layout

    No, QListView does not use any kind of layout for laying it's items.
    You have a few properties to change the way how items in a list view are laid, but there is no such feature as you are looking for.
    J-P Nurmi

  3. #3
    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

    my mistake...i intended to say QListView or Grid layout. Can't I achieve the above at all in Qt...???

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

    Default Re: Grid layout

    Writing a custom layout which allows you to lay items in corners and edges is simple enough.
    Take a look at Qt's Border Layout example.
    The custom layout given in the example is a good basis to start with, it doesn't need too much modifying to achieve same kind of behavior than you described.
    J-P Nurmi

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

    nupul (20th April 2006)

  6. #5
    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

    Well thanks for the pointer. You see my custom widget is going to be of a fixed size...is there any alternative like setGeometry to position the icons exactly where i want to?

    Thanks

  7. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 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

  8. #7
    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

  9. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 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

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