Results 1 to 5 of 5

Thread: How to use a button/widget as item for QListWidget?

  1. #1
    Join Date
    Apr 2008
    Posts
    39
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to use a button/widget as item for QListWidget?

    Hi!

    I want to place one or more buttons into a QListWidgetItem to enable a choice at a certain position/item in the QListWidget.

    It doesn't have to be a button, a simple text-link would be enough.

    Is it possible?

    So long

  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 use a button/widget as item for QListWidget?

    Why cant u use QListWidget::itemClicked ??
    Also to give effect of link, you can change the mouse cursor if its in the ListWidget

  3. #3
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to use a button/widget as item for QListWidget?

    you can also use
    Qt Code:
    1. void QListWidget::setItemWidget ( QListWidgetItem * item, QWidget * widget )
    To copy to clipboard, switch view to plain text mode 
    but I agree with aamer4yu

  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 use a button/widget as item for QListWidget?

    From the docs -
    void QListWidget::setItemWidget ( QListWidgetItem * item, QWidget * widget )
    Sets the widget to be displayed in the give item.
    This function should only be used to display static content in the place of a list widget item. If you want to display custom dynamic content or implement a custom editor widget, use QListView and subclass QItemDelegate instead.
    Also using a widget wont be a good idea when u can get the work done without it. Why make ur application heavy

  5. #5
    Join Date
    Apr 2008
    Posts
    39
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to use a button/widget as item for QListWidget?

    Thanks for your answers.

    I realized it with a context menu. But "setItemWidget" seems to be interesting.

    Bye

Similar Threads

  1. Item Delegate Painting
    By stevey in forum Qt Programming
    Replies: 3
    Last Post: 9th May 2008, 07:37
  2. Replies: 1
    Last Post: 19th April 2007, 22:23
  3. how change the QListBox item position by pixel
    By roy_skyx in forum Qt Programming
    Replies: 2
    Last Post: 20th January 2006, 01:34

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.