×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    38

    QListWidget with buttons for each item

    I want a delete button (or a checkbox) for each QListWidgetItem.
    How to achieve?
    Should I draw that in my delegate.paint() / QTableWidget? Or is there a simpler way?
    Thanks in advance

  2. #2
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: QListWidget with buttons for each item


  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    38

    Re: QListWidget with buttons for each item

    Quote Originally Posted by danhicksbyron View Post
    i have this, should be doing the same thing right?
    ui->myListWidget->setItemDelegate(new MyItemDelegate);

    MyListItem *item = new MyListItem(ui->myListWidget);
    item->populateItemData();
    item->setFlags(item->flags()|Qt::ItemIsUserCheckable);

    but how to add the button? get the button's state (when it's clicked etc)?

  4. #4
    Registered User
    Join Date
    Oct 2010
    Posts
    38

    Re: QListWidget with buttons for each item

    hmm, I just got it to show check boxes by adding
    item->setCheckState(Qt::Unchecked);, not sure why i couldn't get it to work before
    thanks anyways danhicksbyron

  5. #5
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: QListWidget with buttons for each item

    Create a widget with a button in it.

  6. #6
    Registered User
    Join Date
    Oct 2010
    Posts
    38

    Re: QListWidget with buttons for each item

    Thanks, I will try that.

    For the checkboxes, I can't get them to show up on S60.

    for(int row = 0; row < 10; ++row){
    QListWidgetItem* item = new QListWidgetItem("item", ui->myListWidget);
    item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
    item->setCheckState(Qt::Unchecked);
    }

    any idea where I could have done wrong?

  7. #7
    Nokia Developer Expert
    Join Date
    Feb 2008
    Posts
    183

    Re: QListWidget with buttons for each item

    There was a bug, which has been corrected to 4.7.1 release of Qt.
    Here: http://bugreports.qt.nokia.com/browse/QTBUG-11150

Similar Threads

  1. Replies: 4
    Last Post: 2010-10-05, 07:09
  2. Replies: 8
    Last Post: 2010-06-10, 18:03
  3. Replies: 3
    Last Post: 2010-02-13, 14:47
  4. Replies: 2
    Last Post: 2008-07-01, 02:01

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×