M
M
Mercury132016-01-18 19:24:13
Qt
Mercury13, 2016-01-18 19:24:13

Qt: how to make wide combobox?

There is a table. In it, we set some settings through the combobox (only selection, no input). We overcame most of the technical problems, stumbled upon another one.
Texts are planned to be quite long (especially in localizations), and I would like to make the drop-down list wide. Approximately like this.
e62610369b304c6fa717b0a5260025b2.png
How to implement this in Qt? It is desirable that it also selects its width according to the actual width of the lines.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
EXL, 2016-01-19
@Mercury13

Here it is suggested to overload the showPopup() method :

void MyComboBox::showPopup()
{
    this->view()->setMinimumWidth(this->view()->sizeHintForColumn(0));
    QComboBox::showPopup();
}

Search Google for KeyWord: " QComboBox popup width ".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question