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:
UserSettingsDialog
::UserSettingsDialog(QMainWindow *parent
) :{
setWindowTitle
(QString::fromUtf8 ("User Settings"));
createPage ("Display Format");
createPage ("Window Size");
connect (mListWidget,
this,
}
UserSettingsDialog::UserSettingsDialog(QMainWindow *parent) :
QMainWindow (parent), mStackedWidget (0)
{
setWindowTitle(QString::fromUtf8 ("User Settings"));
createPage ("Display Format");
createPage ("Window Size");
connect (mListWidget,
SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
this,
SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*)));
}
To copy to clipboard, switch view to plain text mode
void UserSettingsDialog
::createPage (const QString &pageName
) {
SettingPage *page = new SettingPage (pageName,
CSMSettings::UserSettings::instance().settingModel(), false, this);
mStackedWidget->addWidget (&dynamic_cast<QWidget &>(*(page->pageFrame())));
//////////////////////////////////
// QListWidget item constructed and added to the list widget here
//finishing touches
int textWidth = fm.width(page->objectName());
mListWidget->setMinimumWidth(textWidth + 50);
resize (mStackedWidget->sizeHint());
}
void UserSettingsDialog::createPage (const QString &pageName)
{
SettingPage *page = new SettingPage (pageName,
CSMSettings::UserSettings::instance().settingModel(), false, this);
mStackedWidget->addWidget (&dynamic_cast<QWidget &>(*(page->pageFrame())));
//////////////////////////////////
// QListWidget item constructed and added to the list widget here
new QListWidgetItem (page->objectName(), mListWidget);
//finishing touches
QFontMetrics fm (QApplication::font());
int textWidth = fm.width(page->objectName());
mListWidget->setMinimumWidth(textWidth + 50);
resize (mStackedWidget->sizeHint());
}
To copy to clipboard, switch view to plain text mode
Bookmarks