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 ensuring the SizeAdjustPolicy is actually being used 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 … Read more

How to set QComboBox to item from item’s text in PyQt/PySide

Yes, there is QComboBox.findText, which will return the index of the matched item (or -1, if there isn’t one). By default, the search does exact, case-sensitive matching, but you can tweak the behaviour by passing some match-flags as the second argument. For example, to do case-insensitive matching: index = combo.findText(text, QtCore.Qt.MatchFixedString) if index >= 0: … Read more

How do I set the background color of a widget like combobox or double spin box?

fhe is generally correct, but doesn’t account for the widgets (like spin boxes and buttons/comboboxes) that use a different background role in the palette. A more general solution would be something like this: QPalette pal = widget.palette(); pal.setColor(widget.backgroundRole(), Qt::blue); widget.setPalette(pal); Alternatively, you could look into the descriptions of the various palette roles and figure out … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)