Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Accessing functions from a custom item in a QListWidget?
Forum Updated to NodeBB v4.3 + New Features

Accessing functions from a custom item in a QListWidget?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 847 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Thegreger
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved