Home > Back-end >  About button in QListWidgetItem trough links
About button in QListWidgetItem trough links

Time:10-05

As title, to add a delete button, QListWidgetItem Qt interface has been implemented, but the delete button to connect always do not know how, seek guidance,
The code below

Void CCopyrightWgt: : AddFiles ()
{
QStringList fileNames=QFileDialog: : getOpenFileNames (this,
QString: : fromUtf16 "open" (L),
,
"."QString: : fromUtf16 (L "all files (*. *)")
);
//
Int FileNum=fileNames. The count ();

if (! FileNames. IsEmpty ())
{
M_pUi - & gt; LwFiles - & gt; SetSelectionMode (QAbstractItemView: : SelectionMode: : SingleSelection);//set the radio mode
M_pUi - & gt; LwFiles - & gt; SetResizeMode (QListView: : Adjust);
M_pUi - & gt; LwFiles - & gt; SetAutoScroll (true);

For (int index=0; Index{
QWidget * wgtContainter=new QWidget;
QHBoxLayout * hLayout=new QHBoxLayout (wgtContainter);
QPushButton * pDeleteBtn=new QPushButton;

//interception filename shows
QString file_name=QFileInfo (fileNames [index]). The fileName ();
QLabel * filename=new QLabel (file_name);

PDeleteBtn - & gt; SetText (QString: : fromUtf16 (L "delete"));
PDeleteBtn - & gt; The resize (45, 20);

HLayout - & gt; AddWidget (filename);
HLayout - & gt; AddStretch (1);
HLayout - & gt; AddWidget (pDeleteBtn);
HLayout - & gt; 5,0,0,5 setContentsMargins ();

WgtContainter - & gt; SetLayout (hLayout);
WgtContainter - & gt; Show ();

QListWidgetItem * fileItem=new QListWidgetItem (m_pUi - & gt; LwFiles);
M_pUi - & gt; LwFiles - & gt; SetItemWidget (fileItem wgtContainter);
FileItem - & gt; SetSizeHint (QSize (600, 40));
FileItem - & gt; Xff6db7f0 setBackgroundColor (0);
FileItem - & gt; SetToolTip (fileNames [index]);


}
}
The connect (pDeleteBtn, SIGNAL (clicked ()), wgtContainter, SLOT (RemoveItem ()));//connect failure here, how to modify, realizes the delete button SLOT
}
  • Related