QListWidget, prompt before currentItemChanged signal
-
@SPlatten said in QListWidget, prompt before currentItemChanged signal:
Can anyone see why the pendingSelect select signal isn't occurring?
How should anyone know?
What is clsQtAskBeforeChange and when does it emit pendingSelect signal?class clsQtAskBeforeChange : public QItemSelectionModel { Q_OBJECT Q_DISABLE_COPY_MOVE(clsQtAskBeforeChange) public: using QItemSelectionModel::QItemSelectionModel; QModelIndexList mobjLastIdxList; public slots: void select(const QItemSelection& crobjSelection ,QItemSelectionModel::SelectionFlags flgsCmd) override { QModelIndexList objIdxList(crobjSelection.indexes()); if ( mobjLastIdxList == objIdxList ) { return; } mobjLastIdxList = objIdxList; emit pendingSelect(crobjSelection, flgsCmd); } virtual void actuallySelect(const QItemSelection& crobjSelection ,QItemSelectionModel::SelectionFlags flgsCmd) { QItemSelectionModel::select(crobjSelection, flgsCmd); } signals: void pendingSelect(const QItemSelection& crobjSelection ,QItemSelectionModel::SelectionFlags flgsCmd); };
After posting this I though it might be the check:
if ( mobjLastIdxList == objIdxList ) { return; }
Causing it to return, but it isn't.
-
class clsQtAskBeforeChange : public QItemSelectionModel { Q_OBJECT Q_DISABLE_COPY_MOVE(clsQtAskBeforeChange) public: using QItemSelectionModel::QItemSelectionModel; QModelIndexList mobjLastIdxList; public slots: void select(const QItemSelection& crobjSelection ,QItemSelectionModel::SelectionFlags flgsCmd) override { QModelIndexList objIdxList(crobjSelection.indexes()); if ( mobjLastIdxList == objIdxList ) { return; } mobjLastIdxList = objIdxList; emit pendingSelect(crobjSelection, flgsCmd); } virtual void actuallySelect(const QItemSelection& crobjSelection ,QItemSelectionModel::SelectionFlags flgsCmd) { QItemSelectionModel::select(crobjSelection, flgsCmd); } signals: void pendingSelect(const QItemSelection& crobjSelection ,QItemSelectionModel::SelectionFlags flgsCmd); };
After posting this I though it might be the check:
if ( mobjLastIdxList == objIdxList ) { return; }
Causing it to return, but it isn't.
-
@jsulm, as far as I can see with a breakpoint on the first line in the select function, no it isn't.
-
-
@SPlatten How should I know?!
You did not even tell us to what signal select() is connected! -
@jsulm , I'm not asking out specifically....looking at the class, its derived from QItemSelectionModel:
https://doc.qt.io/qt-5/qitemselectionmodel.html#signals@SPlatten said in QListWidget, prompt before currentItemChanged signal:
QItemSelectionModel
OK, did not notice this
-
@Christian-Ehrlicher , thank you, I can see that the select slot is getting called, but it appears that it is being called after the currentItemChanged signal, which is wrong isn't it?
-
@Christian-Ehrlicher , thank you, I can see that the select slot is getting called, but it appears that it is being called after the currentItemChanged signal, which is wrong isn't it?
@SPlatten said in QListWidget, prompt before currentItemChanged signal:
which is wrong isn't it?
Why? Is it written down somewhere? And from my pov a cell has to be the current one until the selection can change.
-
@SPlatten said in QListWidget, prompt before currentItemChanged signal:
which is wrong isn't it?
Why? Is it written down somewhere? And from my pov a cell has to be the current one until the selection can change.
@Christian-Ehrlicher , the intention is that when the user tries to make a new selection, an interim step checks that its ok to allow the change, by checking other content using the slot...it can then allow or disallow the selection.
-
@SPlatten said in QListWidget, prompt before currentItemChanged signal:
which is wrong isn't it?
Why? Is it written down somewhere? And from my pov a cell has to be the current one until the selection can change.
@Christian-Ehrlicher , @jsulm , I think I've been going down a rabbit hole in trying to implement this model, when all I actually need to do is move the test for change into the slot and then if I don't want to allow the selection change assign QListWidgetItem* pobjCurrent to QListWidgetItem* pobjPrevious.