PDA

View Full Version : How to create select and delete in qFrame?



akkarachai
9th September 2019, 08:59
I have created the program that when clicked the button the picture will show on QFrame but I don't know how to create Function that can select the picture and delete them?


here is my code:
DragWidget::DragWidget(QWidget *parent)
: QFrame(parent)
{
QToolBar *pToolBar = new QToolBar(this);
m_ActADD = new QAction(this);
m_ActADD->setIcon(QIcon(":/images/add.png"));
connect(m_ActADD, &QAction::triggered, this, &DragWidget::addLableStrip);
m_ActRemove = new QAction(this);
m_ActRemove->setIcon(QIcon(":/images/remove.png"));
connect(m_ActRemove, &QAction::triggered, this, &DragWidget::addLableStrip);

pToolBar->addAction(m_ActADD);
pToolBar->addAction(m_ActRemove);
setMinimumSize(700, 700);
setFrameStyle(QFrame::Sunken | QFrame::StyledPanel);
setAcceptDrops(true);

}

void DragWidget::addLableStrip(){
QLabel *boatIcon = new QLabel(this);
boatIcon->setPixmap(QPixmap(":/images/strip"));
boatIcon->move(10, 50 + moved);
moved += 70;
boatIcon->show();
boatIcon->setAttribute(Qt::WA_DeleteOnClose);
}

1325413254

the green button is for add the picture
and the red button for delete the picture (this button I want to create the fucntion that can selete and delete the picture)

ChrisW67
9th September 2019, 09:46
Perhaps you may want to consider QListWidget (or QListView with a model) in IconMode.

akkarachai
9th September 2019, 10:13
thank you for your answer.

could you give me some example?

sorry i'm rookie.:)