Results 1 to 7 of 7

Thread: How to build a list of custom widgets

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2010
    Posts
    16
    Qt products
    Qt Jambi
    Platforms
    Unix/X11 Symbian S60 Maemo/MeeGo

    Default Re: How to build a list of custom widgets

    Okay, I see your point but I want the icon to span the 2 rows, can I do it using Grid Layout?

    Moreover, do you know how I can insert my custom widget into my ListView?

    Thanks.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to build a list of custom widgets

    but I want the icon to span the 2 rows, can I do it using Grid Layout?
    Sure. Read documentation for QGridLayout
    Why do you want to use ListView ? inserting custom widget is heavy and should not be done for many cells..
    Whats your requirement ?

  3. #3
    Join Date
    Jul 2010
    Posts
    16
    Qt products
    Qt Jambi
    Platforms
    Unix/X11 Symbian S60 Maemo/MeeGo

    Default Re: How to build a list of custom widgets

    What I want is to build a list. The problem is that it is not a basic list.

    Every element of this list must be composed of the layout previously described (some text on the left, in the middle and an icon on the right)

    This is how a single element of the list should look like:

    | text here ################################ text here ### ICON |
    | other text here (might be in different style) ##### text here ### ICON |

    The ICON spans the 2 rows.

    So my idea was to build a widget representing a single element of the list and then add several widgets to the list.

    Please tell me if something is still not clear.

    Thanks again.

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to build a list of custom widgets

    It would be better if you go for delegates then. See QItemDelegateIn the paint function you can calculate the rects yourself and draw text and place icons as per your requirement.

    Other ways wont be as efficient as using delegates. Also see setItemData with which you can set different text you need..

Similar Threads

  1. Replies: 1
    Last Post: 18th July 2012, 09:59
  2. List of child widgets includes layout
    By JovianGhost in forum Qt Programming
    Replies: 5
    Last Post: 11th May 2010, 03:22
  3. Replies: 0
    Last Post: 15th May 2009, 15:38
  4. List of Widgets
    By linuxdev in forum Qt Tools
    Replies: 3
    Last Post: 30th April 2009, 14:24
  5. Custom widget in list view
    By fusoin23 in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2006, 14:09

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.