[Qt-interest] Initial text selection in dialogs

Kaleb Pederson kaleb.pederson at gmail.com
Wed Jun 17 17:59:36 CEST 2009


On Wed, Jun 17, 2009 at 7:57 AM, Kyle Alons<kyle at kinook.com> wrote:
> On Windows, when a dialog is displayed and an edit or editable combo control
> is the first focused field, that field's text is selected.  With a Qt
> application (using 4.5.1), it isn't selected (although it is when tabbing
> away and back to that field).  For instance, see the findfiles example.  How
> to get the proper initial selection behavior on Windows?  Or how to manually
> select the text of an editable QComboBox?  Thanks.

I'd first try comboBox->setFocus(Qt::OtherFocusReason) in the dialog
constructor.  If that didn't work, I'd probably try
comboBox->lineEdit()->selectAll() before setting the focus.

--Kaleb




More information about the Qt-interest-old mailing list