How to generate signal when item is entered by code.
-
I can go down the options or ASK. here .
I need to have signal generated when "item is entered" into QListWidget list by another signal.
No manual selection.QtDesigner suggests "go to slot " options and I have tried
currentItemChanged
currentTextChanged
itemChanged
itemEntered -
@AnneRanch
You mean "added"?
"Enter" in this case means, your mouse enters the item. -
@AnneRanch said in How to generate signal when item is entered by code.:
Lets define "current" next
"current" means the current / active (focused) item in your
QListWidget
.
For example,currentItemChanged
passes the last and the new/current focused item to your slot. -
@AnneRanch what you're looking for is probably signals. coming from the underlying model that QListWidget implements
https://doc.qt.io/qt-5/qabstractitemmodel.html#signals
I don't think you can get access to the model from a QListWidget, you will have to use a QListView and manage your own Model, that you can listen to
Or define your own signal, that you emit, when you add staff to the QListWidget
-
@Pl45m4 said in How to generate signal when item is entered by code.:
@AnneRanch said in How to generate signal when item is entered by code.:
Lets define "current" next
"current" means the current / active (focused) item in your
QListWidget
.
For example,currentItemChanged
passes the last and the new/current focused item to your slot.That is not that clear.
"passes" implies the item is again selected - by mouse or keyboard.
"focused" is same - the item is selected - by mouse or keyboard.I need to process the item BEFORE it is added to the list.
@J-Hilk said in How to generate signal when item is entered by code.:
@AnneRanch what you're looking for is probably signals. coming from the underlying model that QListWidget implements
https://doc.qt.io/qt-5/qabstractitemmodel.html#signals
I don't think you can get access to the model from a QListWidget, you will have to use a QListView and manage your own Model, that you can listen to
and you are correct
Or define your own signal, that you emit, when you add staff to the QListWidget
See my next to last post - process the item signal - BEFORE - it get added to the list.
Sort to messes up the logical flow of events, but definitely simplify the process. -
@AnneRanch said in How to generate signal when item is entered by code.:
See my next to last post - process the item signal - BEFORE - it get added to the list.
If you do it on your own, you can decide when you emit it.
Write your ownaddItem
function, emit your custom signal in there and then actually add your item to yourQListWidget
. -
Hi
Its also possible to doauto m = ui->listWidget->model() ; connect(m, &QAbstractItemModel::rowsInserted, this, [m](const QModelIndex &parent, int first, int last){ m->setData(m->index(first,0/*col*/), "replaced!" ); } ); ui->listWidget->addItem("JUBII");