我有一个QComboBox
我填写的QString
使用:
comboBox->addItem(someString);
当我启动我的 GUI 应用程序时,宽度QComboBox
总是 70,即使最小的项目要大得多。QComboBox
例如,如何动态地将 a 的宽度设置QString
为comboBox
?
编辑:
经过进一步测试,我找到了以下解决方案:
// get the minimum width that fits the largest item.
int width = ui->sieveSizeComboBox->minimumSizeHint().width();
// set the ComboBoxe to that width.
ui->sieveSizeComboBox->setMinimumWidth(width);