Hi
What, precisely, controls the default width of a QListWidget. I want a list widget that makes itself exactly wide enough to display the width of its widest item but no more.
E.g. I would have expected the following simple code to produce a dialog with a list box exactly wide enough to hold the items "fred" and "bloggs" but no more. Yet the dialog that gets shown has a list widget some 5 times wider than necessary. Why?
pLayout->addWidget(pListWidget);
dlg.setLayout(pLayout);
dlg.exec();
QDialog dlg(this);
QListWidget* pListWidget = new QListWidget();
new QListWidgetItem("Fred", pListWidget);
new QListWidgetItem("Bloggs", pListWidget);
QVBoxLayout* pLayout = new QVBoxLayout();
pLayout->addWidget(pListWidget);
dlg.setLayout(pLayout);
dlg.exec();
To copy to clipboard, switch view to plain text mode
What is the simplest, clean and reliable way to control the list width width without relying on pixel width constants. Code needs to be properly portable. Thanks
Bookmarks