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:
item = new TaskItem;
list->insertItem(0, "asdsa");
list->setItemWidget(list->item(0), item);
layout->addWidget(list);
layout = new QVBoxLayout(this);
item = new TaskItem;
list = new QListWidget;
list->insertItem(0, "asdsa");
list->setItemWidget(list->item(0), item);
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
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?
Bookmarks