CodePudding user response:
you need to set up three things1. QWidget * widget=new QWidget ();
2. Is the item you want to build (such as label, button)
QLabel * lab1=new QLabel ();
QLabel * lab2=new QLabel ();
QLabel * lab3=new QLabel ();
QPushButton * btn1=new QPushButton ();
3. Create a layout QHBoxLayout *=new QHBoxLayout (widget);
And set up layout inside your entries added:
Layout - & gt; AddWidget (lab1);
Layout - & gt; AddWidget (lab2);
Layout - & gt; AddWidget (lab3);
Layout - & gt; AddWidget (btn1);
Add your label and button to set a name with the setText, then in the widget - & gt; SetLayout (layout);
last as long as you in your listwidget addItem, then setItemWidget (item variable name, widgets), it is good,
this idea is: to create your entry to put them into a widget, then add listwidget items, setting up setItemWidget put you build widgets in go well,
QListWidgetItem * aItem=new QListWidgetItem ();
The UI - & gt; ListWidget - & gt; AddItem (aItem);
The UI - & gt; ListWidget - & gt; SetItemWidget (aItem, widget);