PDA

View Full Version : QCompleter popup width



Thuan Seah Tan
1st December 2011, 00:49
Hi everyone,

I am using the QCompleter to present the user a list of options for my QLineEdit widget. The QLineEdit widget resides in another custom widget which resizes itself based on the text entry. With no text entered, the width defaults to the size of 1 character. The problem I encounter with QCompleter was based on the source code is that the width of the popup is directly related to the width of the widget (in this case the QLineEdit) it is providing the completion for. So even if my list of options contains a string say "A123456", the width of the popup will still be that of the QLineEdit.

Currently I am using a dummy QCompleter and popup to calculate the width for the longest string in the auto completion options and then resizing the QLineEdit object to fit that width.

Wondering is there a better or less hacky approach to this problem? Basically I want the popup to be wide enough to view all options without a scrollbar irregardless of the width of the widget it is providing completion for.

Thuan