我有一个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);