[SOLVED]How to delete an item from the treeview by droping an item to pushbutton or to an group box
-
@Ratzz said:
But i do not want the user to allow listview items to dragged to pushbutton/groupbox
So why can you not check there ?
also
http://doc.qt.io/qt-5/qtreewidget.html#dropMimeData
Seems to be when something is dropped on Tree and im confused what it has to do with the
Groupbox ? -
@Ratzz
And the DragGBox do have
void dragEnterEvent(QDragEnterEvent* event) {
event->acceptProposedAction();
}So why cant you just check that sender if the accepted one and then acccept or if not then
reject the drop? -
@mrjj said:
For the DropGroupBox class.
I assume you use that one? -
STOP
sender() not working for events it seems.
So cannot work.
So its a no go. -
@Ratzz
you can use
QWidget * QDropEvent::source() const -
@Ratzz
almost but must be the type you want to allow
QTreeView * theone= dynamic_cast<QTreeView*>(event->source());
if( theone != NULL )
{
event->acceptProposedAction();
}so it says if it IS a Treeview then say ok
For other types, it should not allow then. (red sign)
I hope :) -
@Ratzz
Super :) -
@mrjj
when i click delete button i doui->label->setText(QString::number(parent->rowCount()));
which gives me count of the number of rows. But if i drag the row will be deleted but count is not getting updated. how to update it ?
Should it be done onGroupDropBox
?? -
@Ratzz
GroupBox would not know about parent.
The Tree should update when the It is removed.But then you drag, do you call the buttons on_click so the
ui->label->setText(QString::number(parent->rowCount()))
is executed ?
The groupBox example does not call anything as the Tree removes the item it self so
I assume that is why you dont see Count Changes. -
Hi
you could also cheat a bit and use a timer.QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(updateMinorFrameCount()));
timer->start(1000);
46/54