Accessing functions from a custom item in a QListWidget?
-
So this one is a bit complicated... I currently have a QListWidget, where all the items are of a custom class based on QFrame. This frame contains a number of labels, and a QwtPlot object. Constructing it has been straightforward, and I can neatly add or remove rows of items. However, what I'm looking for is a way to access the children of my ListItem.
The custom class I'm using will define a frame, a layout and child objects within this frame. I also have a function called RefreshPlot for refreshing the plot and/or some of the labels. Now, I can add the item and access the refresh function like this:
@TuneCaseList *frame1 = new TuneCaseList(this);
QListWidgetItem *item = new QListWidgetItem();
item->setSizeHint(QSize(0,65));ui->caseList->addItem(item);
ui->caseList->setItemWidget(item,frame1);
frame1->RefreshPlot();@Let's say that I wanted to access the RefreshPlot function for one of the items in my list from a different subroutine. Could I do this by going via the ListItem? Basically, what I would want is to call the RefreshPlot function for the item at a particular row in my QListWidget.
A pseudo-code of what I would like to do is something like:
@ ui->caseList->item(2)->listWidget()->RefreshPlot();@but of course the compiler at this point doesn't know that I'm using that particular class for my listWidget.
Would something like this be possible to do? Of course, I could simply remove the item from my list, and re-insert it on the same position, but that isn't a very good-looking solution.
I should add that I'm still somewhat new to Qt, so apologies if the code snippet is a bit clumpsy.