[Qt-interest] Trouble preselecting an item in a QCombobox using a QModelIndex

Stephen Kelly steveire at gmail.com
Tue Dec 9 02:00:55 CET 2008


Matthew Huck wrote:

>> I've sent a report to qt-bugs and asked on kde-devel too.
>>http://lists.kde.org/?l=kde-devel&m=121314573327184&w=2
> 
>>I'm still interested in a workaround if anyone has another idea.
>>Best regards,
>>Steve.
> 
> There is a little bit of black magic that works without the need for a
> proxy model.
> 
> If you call
> 
> QMetaObject::invokeMethod(yourComboBox,
> "_q_itemSelected",Qt::DirectConnection, QGenericReturnArgument(),
> Q_ARG(QModelIndex,yourModelIndex));
> 
> You'll get the effect you're after, but be warned, that
> _q_itemSelected is private and can change at any time.
> 
> 
> Cheers
> 
> Matthew


Hmm, thanks I might look into that. Currently I iterate over the items in
the model until I find what I'm looking for, then set the row of the
combobox from the found index.

Cheers,

Steve 
(Oldish thread, eh:))



More information about the Qt-interest-old mailing list