How do I set the QComboBox width to fit the largest item?

Qt (4.6) online documentation has this to say about QComboBox:

enum    SizeAdjustPolicy  { AdjustToContents, AdjustToContentsOnFirstShow, AdjustToMinimumContentsLength, AdjustToMinimumContentsLengthWithIcon }

I would suggest

  1. ensuring the SizeAdjustPolicy is actually being used

  2. setting the enum to AdjustToContents. As you mention a .ui file I suggest doing that in Designer. Normally there shouldn’t be anything fancy in your constructor at all concerning things you do in Designer.

Leave a Comment

tech