Results 1 to 3 of 3

Thread: QListWidget Custom item is not there

  1. #1
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QListWidget Custom item is not there

    I've created a QListWidget, And I also Created a TaskItem.
    In Main Window I have a layout. When i add TaskItem to the layout - I can see it. When i Add QListWidget to the layout I can see it. But when i try to add TaskItem to the QListWidget and then show that QListWidget, The TaskItem is not displayed. here is the relevant code:

    Qt Code:
    1. layout = new QVBoxLayout(this);
    2. item = new TaskItem;
    3. list = new QListWidget;
    4. list->insertItem(0, "asdsa");
    5. list->setItemWidget(list->item(0), item);
    6.  
    7. layout->addWidget(list);
    To copy to clipboard, switch view to plain text mode 

    If i compile this code, I see the ListWidget with one item "asdsa" inside, when i should see TaskItem...


    Added after 27 minutes:


    Hm... I'm an idiot
    I had to set TaskItem's widget size bigger...

    Now I have another question:
    I created a QScrollArea, in which I placed the QListWidget.
    Everything works, but i want the scrollbar to move smooth (right now it jumps from first item to the second if i move the scrollbar)...

    Now I found out that the problem is not in QScrollArea, but in the QListWidget itself (i can use QListWidget Without QScrollArea, but it still does not move smooth, but in jumps...


    Solved this one also.
    Had to use
    Qt Code:
    1. list->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
    To copy to clipboard, switch view to plain text mode 

    Now is the biggest Question: How do i catch a signal, that the button of one TaskItem in the QListWidget has been pressed?
    Last edited by Archa4; 6th May 2011 at 10:26.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QListWidget Custom item is not there

    Your widget has to emit this signal by itself. It is not tied to the QListWidget in any way other than that it occupies space meant for a list item.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QListWidget Custom item is not there

    Ok, but how do u catch the signal from anyone of those TaskItems?

Similar Threads

  1. How to add a custom item in a QlistWidget??
    By druidamix in forum Qt Programming
    Replies: 1
    Last Post: 16th September 2010, 20:19
  2. Replies: 5
    Last Post: 10th August 2009, 10:50
  3. QListWidget Item
    By csvivek in forum Qt Programming
    Replies: 1
    Last Post: 15th June 2008, 09:02
  4. remove item from QListWidget
    By yushinee in forum Newbie
    Replies: 3
    Last Post: 2nd October 2007, 20:40
  5. Reg - add item in QListWidget
    By suresh in forum Newbie
    Replies: 1
    Last Post: 1st September 2006, 17:52

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.