Results 1 to 3 of 3

Thread: [QT4] QListWidget:: setItemSelected misbehaving?

  1. #1
    Join Date
    Feb 2006
    Location
    USA
    Posts
    142
    Thanks
    24
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default [QT4] QListWidget:: setItemSelected misbehaving?

    I've got an interesting problem...

    Within my code, I am setting an item as selected in a QListWidget within the constructor of the dialog it is embedded in. I use the following code to do so:
    Qt Code:
    1. ui.listWidgetDatabaseDrivers->setItemSelected(ui.listWidgetDatabaseDrivers->findItems(in.readLine(), Qt::MatchExactly)[0], true);
    To copy to clipboard, switch view to plain text mode 

    What this does, is read a driver name from a file and match it up with something in the list. Visually, it works. The dialog shows up, and the correct item is highlighted. Programmatically, Qt thinks that nothing has been selected.

    For example, this code checks what is selected:
    Qt Code:
    1. if(listWidgetDatabaseDrivers->selectedItems().isEmpty())
    2. {
    3. //Then it's not OK to proceed
    4. }
    To copy to clipboard, switch view to plain text mode 

    Until I actually go in and click the driver myself, it's not detected that this has been selected.

    Is there something I am missing?
    Life without passion is death in disguise

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: [QT4] QListWidget:: setItemSelected misbehaving?

    This may be a bug. There are other situations where selections go out of sync too.

  3. #3
    Join Date
    Feb 2006
    Location
    USA
    Posts
    142
    Thanks
    24
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: [QT4] QListWidget:: setItemSelected misbehaving?

    I was afraid of that. Looks like I'll need to upgrade to 4.1.1 and see if this is still a problem there... if so, I'll fill in a bug report.

    I'm currently running on 4.0.1, so for all I know it has already been fixed. I'll just need to re-compile it.
    Life without passion is death in disguise

Similar Threads

  1. [Qt4]: Adding centered items in QListWidget
    By Jojo in forum Qt Programming
    Replies: 4
    Last Post: 16th March 2006, 20:04

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.