[Qt-interest] How do I show a list of complex items (like firefox's download list)?

Girish Ramakrishnan girish at forwardbias.in
Tue Jan 6 06:32:39 CET 2009


Witteveen, Arnt wrote:
> (To those who are also member of [Qt4-preview-feedback, I've asked this
> there before, but some one pointed out this list as a better one for
> this question.)
> 
> I'm looking to make something very much like firefox's (or most other
> browsers, I guess) list of things downloaded: a list of compound
> widgets, which each widget containing an icon, a few labels, a button or
> 2 and somehting like a progress bar (for some of the time, until it is
> completed).
> 
> I've tried (and failed) using QListView with a drawing delegate. Even if
> that would work, I think it would only draw things like the button, but
> not make the interaction on them work. Then I switched to QListWidget. I
> can set the default QT widgets using setItemWidget, but as soon as I try
> to set a derived widget which is composed of serveral others, that
> doesn't do anything? I tried the widget outside the listview and it does
> work as expected. This is what I did (for testing, the widget I tried
> just shows a fixed label and button):
> 
>     QVBoxLayout* theListLayout = new QVBoxLayout(this);
>     setLayout(theListLayout);
> 
>     QListWidget* theListView = new QListWidget();
>     theListLayout->addWidget(theListView);
> 
>     QListWidgetItem* theItem1 = new QListWidgetItem(tr("t1") );
>     theListView->addItem(theItem1);
>     theListView->addItem(tr("t2"));
>     theListView->addItem(tr("t3"));
> 
>     QWidget* theWidget1 = new QWidget();
>     QHBoxLayout* theItemLayout = new QHBoxLayout();
>     theWidget1->setLayout(theItemLayout);
>     theItemLayout->addWidget( new QPushButton(tr("a")));
>     theItemLayout->addWidget( new QLabel(tr("b")));
> 
> 
>     theListView->setItemWidget(theListView->item(1), theWidget1);
>     theListView->setItemWidget(theListView->item(2), new
> QPushButton(tr("ttt")));
> 
>     //to test the widget: this does work: theListLayout->addWidget(
> theWidget1);
> 
> So unless the above should work and I do somehting wrong, all I can now
> think of is to do it all manually, with a scrollarea containing all the
> widgets I need?
> 

This looks like a bug in Qt. I did a quick check with QTreeWidget but it
manages to show the index widget only of the first item.

I think a QScrollArea is more suited. I cannot see any advantage of
using itemviews for your purpose.

Girish



More information about the Qt-interest-old mailing list