Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, June 2007
QListWidget::setItemWidget???


Message 1 in thread

I can't seem to get this function to work at all, what is it supposed to
do?  What I want to be able to do is to have a QListWidget that I extend
that contains items that are user interactable (such as a QPushButton 
and a QComboBox).  It looks like setItemWidget should do exactly what I 
want it to do, but it doesn't - it always places the actual 
QTableWidgetItem on top of the widget I pass setItemWidget.  What am I 
doing wrong? Here's what I'm doing:

	QListWidgetItem *listItem = new QListWidgetItem(tr("Filter Item"));
	//The following is valid because QListWidget is being extended
	addItem(filterItem);

	QComboBox *com = new QComboBox();
	com->addItem("1");
	com->addItem("2");
	com->addItem("3");
	
	QPushButton *but = new QPushButton();
	but->setText("+");

	QBoxLayout *layout = new QBoxLayout(QBoxLayout::LeftToRight);
	layout->addWidget(but);
	layout->addWidget(com);
	QWidget *widget = new QWidget();
	widget->setLayout(layout);

	setItemWidget(listItem, widget);
	widget->show();

It works fine if I pick one widget (QComboBox or QPushButton), but not 
when I combine widgets in this way.  Any help is greatly appreciated. 
Thanks,
-Chris Portka

--
 [ signature omitted ] 

Message 2 in thread

Did you debug into the ListView to find out what is happening?  Have you 
tried using a custom delegate with the QListView and a QStandardItemModel?

Chris Portka wrote:
> I can't seem to get this function to work at all, what is it supposed to
> do?  What I want to be able to do is to have a QListWidget that I extend
> that contains items that are user interactable (such as a QPushButton 
> and a QComboBox).  It looks like setItemWidget should do exactly what 
> I want it to do, but it doesn't - it always places the actual 
> QTableWidgetItem on top of the widget I pass setItemWidget.  What am I 
> doing wrong? Here's what I'm doing:
>
>     QListWidgetItem *listItem = new QListWidgetItem(tr("Filter Item"));
>     //The following is valid because QListWidget is being extended
>     addItem(filterItem);
>
>     QComboBox *com = new QComboBox();
>     com->addItem("1");
>     com->addItem("2");
>     com->addItem("3");
>     
>     QPushButton *but = new QPushButton();
>     but->setText("+");
>
>     QBoxLayout *layout = new QBoxLayout(QBoxLayout::LeftToRight);
>     layout->addWidget(but);
>     layout->addWidget(com);
>     QWidget *widget = new QWidget();
>     widget->setLayout(layout);
>
>     setItemWidget(listItem, widget);
>     widget->show();
>
> It works fine if I pick one widget (QComboBox or QPushButton), but not 
> when I combine widgets in this way.  Any help is greatly appreciated. 
> Thanks,
> -Chris Portka
>
> -- 
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>


---

This communication contains confidential information. If you are not the intended recipient please return this email to the sender and delete it from your records.

Diese Nachricht enthält vertrauliche Informationen. Sollten Sie nicht der beabsichtigte Empfänger dieser E-mail sein, senden Sie bitte diese an den Absender zurück und löschen Sie die E-mail aus Ihrem System.

--
 [ signature omitted ]