In wx-widget we can undo any event by calling VETO()
.
Here i am doing my first GUI in QT. I have created a new
node test case 3
.
Now i want that selection on tree should be only allowed to changed till i have not saved this new node. If i have not saved this node at least once, selection change should revert back to this unsaved node test case 3
. To indicate that i have saved the node i am using a global variable signal.
How can i achive it?
I tried something like this but no result.
Inside selection changed event handler
when new node created signal is set, then if i change the treewidget selection i am trying to set the selection of the treewidget to the last item of the treewidget:
QPoint prevPoint;
QModelIndex index;
int count = ui->treeWidgetLeft->topLevelItemCount();
//prevPoint.setX(currentXmlRootNodeNumber +1 );
prevPoint.setX(count);
prevPoint.setY(0);
index = ui->treeWidgetLeft->indexAt(prevPoint);
abortEvent = TRUE;
ui->treeWidgetLeft->selectionModel()->select(index ,QItemSelectionModel::Select);
And check at begning of selection changed event handler:
if (abortEvent) {
abortEvent = false;
return;
}