Results 1 to 6 of 6

Thread: QListWidgetItem doesn't select

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2013
    Posts
    35
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default QListWidgetItem doesn't select

    Ok,

    I'm encountering a problem with the QListWidget and QListWidgetItem. Specifically, the first list widget item can't be selected if I click on the item text. If, however, I click on the blank space to it's right, I can select it just fine. The second item I can select regardless of where I click. What boggles me is that both items are constructed using the same code, so it doesn't seem to be a problem with anything I'm doing.

    I'm using Qt 4.8.5, and no, upgrading to 5.x isn't an option, in case someone suggests it.

    Here's a marked up screenshot illustrating the problem:

    screenshot.png

    And the relevant construction code:


    Qt Code:
    1. UserSettingsDialog::UserSettingsDialog(QMainWindow *parent) :
    2. QMainWindow (parent), mStackedWidget (0)
    3. {
    4. setWindowTitle(QString::fromUtf8 ("User Settings"));
    5.  
    6. createPage ("Display Format");
    7. createPage ("Window Size");
    8.  
    9. connect (mListWidget,
    10. SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
    11. this,
    12. SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*)));
    13. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void UserSettingsDialog::createPage (const QString &pageName)
    2. {
    3.  
    4. SettingPage *page = new SettingPage (pageName,
    5. CSMSettings::UserSettings::instance().settingModel(), false, this);
    6.  
    7. mStackedWidget->addWidget (&dynamic_cast<QWidget &>(*(page->pageFrame())));
    8.  
    9. //////////////////////////////////
    10. // QListWidget item constructed and added to the list widget here
    11.  
    12. new QListWidgetItem (page->objectName(), mListWidget);
    13.  
    14. //finishing touches
    15. QFontMetrics fm (QApplication::font());
    16. int textWidth = fm.width(page->objectName());
    17.  
    18. mListWidget->setMinimumWidth(textWidth + 50);
    19.  
    20. resize (mStackedWidget->sizeHint());
    21. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to graffy for this useful post:


Similar Threads

  1. QListWidgetItem row id
    By Kyosaur in forum Qt Programming
    Replies: 5
    Last Post: 25th October 2013, 07:39
  2. Replies: 9
    Last Post: 9th November 2010, 10:18
  3. Select statemen with bindvalues in Firebird 2 doesn't work
    By corrado1972 in forum Qt Programming
    Replies: 0
    Last Post: 1st September 2010, 15:59
  4. Replies: 4
    Last Post: 4th August 2010, 20:48
  5. about QListWidgetItem
    By Pang in forum Qt Programming
    Replies: 1
    Last Post: 24th March 2007, 09:14

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.