Results 1 to 3 of 3

Thread: New member and a question about QListWidget

  1. #1
    Join Date
    Oct 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Smile New member and a question about QListWidget

    Hi all.

    I just register now and it is my first post here.

    First my presentation: I'm from Spain and I'm trying to learn Qt in order to make multiplatform programs and program for Symbian S60 too.

    Now the question:

    I'm making a single program but cannot find the way to make the next issue:

    I have a QListWidget with checkable items, and I want that when the user checks on one item, it hides automatically. I tried with on_lstList_itemSelectionChanged and with other slots, but it dont works well. It seems that this piece of code is executed before the item is checked (when I debug with QT Creator the signal comes when I just click on item, but the item is not checked until the slot finish), and dont works:


    // If user checks an item, hide it.
    void basket:n_lstList_itemSelectionChanged()
    {
    int i = ui->lstList->currentRow();
    if (ui->lstList->item(i)->checkState() == Qt::Checked) {
    ui->lstList->item(i)->setHidden(true);
    }
    }


    Any ideas to this? Thanks in advice.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: New member and a question about QListWidget

    Hi,

    try QListWidget::itemChanged(). It must be emitted when the check state changes, but I am not sure right now...

  3. #3
    Join Date
    Oct 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: New member and a question about QListWidget

    Lykurg, sorry for the delay, I was ill.

    Thank you very much, it works perfectly, as I wanted. I dont know why I was not able to associate itemChanged with change check item status before.

    Thank you.

Similar Threads

  1. How to use the ui_*.h,inherit it or as a member?
    By 75543255 in forum Qt Programming
    Replies: 1
    Last Post: 30th August 2009, 10:45
  2. question about text alignment in QListWidget
    By to_guliang in forum Qt Programming
    Replies: 3
    Last Post: 21st May 2008, 11:04
  3. problem with forward declaration
    By MarkoSan in forum General Programming
    Replies: 14
    Last Post: 6th January 2008, 21:45
  4. QListWidget Problem
    By pmabie in forum Qt Programming
    Replies: 1
    Last Post: 7th October 2007, 06:52
  5. Replies: 18
    Last Post: 23rd July 2007, 05:58

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.