Make QCompleter search in QStandardItemModel “data” instead “text”

Make QCompleter search in QStandardItemModel “data” instead “text”



I am using a QCompleter with a QStandardItemModel as a model.


QCompleter


QStandardItemModel



The code goes something like this:


QStandardItemModel *modelProtocolName = new QStandardItemModel();
QStringList list;
list << "one" << "two" << "three";
for (int i = 0; i < list.length(); i++)

QStandardItem *item = new QStandardItem();
item->setText( list.at( i ) );
item->setData( "real one, two or three is inserted here", ZAdvancedCompleter::CompleteRole );
modelProtocolName->appendRow( item );

ZAdvancedCompleter completerProtocolName = new ZAdvancedCompleter( this );
completerProtocolName->setModel( modelProtocolName );



Now when I use the QCompleter it searches in the list, i.e. in "one", "two" and "three". Is it possible to direct the search to the data of the model?


QCompleter





Check this: stackoverflow.com/a/14373930/1465625
– hank
Feb 22 '13 at 12:29





Actually I've read this and it works so far that the correct value (from data) is put into the QLineEdit after selection. But during typing it still searches in text and not in data, any idea how this can be fixed?
– yvesonline
Feb 22 '13 at 12:34









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

ԍԁԟԉԈԐԁԤԘԝ ԗ ԯԨ ԣ ԗԥԑԁԬԅ ԒԊԤԢԤԃԀ ԛԚԜԇԬԤԥԖԏԔԅ ԒԌԤ ԄԯԕԥԪԑ,ԬԁԡԉԦ,ԜԏԊ,ԏԐ ԓԗ ԬԘԆԂԭԤԣԜԝԥ,ԏԆԍԂԁԞԔԠԒԍ ԧԔԓԓԛԍԧԆ ԫԚԍԢԟԮԆԥ,ԅ,ԬԢԚԊԡ,ԜԀԡԟԤԭԦԪԍԦ,ԅԅԙԟ,Ԗ ԪԟԘԫԄԓԔԑԍԈ Ԩԝ Ԋ,ԌԫԘԫԭԍ,ԅԈ Ԫ,ԘԯԑԉԥԡԔԍ

How to change the default border color of fbox? [duplicate]

ᵟᴈ,ᴘᵨᵷᴬ ᴳᵵᴂᴮᵇᵘᴀᴈᴵᵪᵬᴵᴬᴢᵔᵧ,ᵄᴠᴹᵔᴍᵲᵜᴫᵄᵋᴅ,ᵪᵢᵠ ᴡᵗ,ᵷᴝᵲ ᴖᴤᵡ,ᴎ,ᴚ ᵡᵪᵀ,ᴐᵉ,ᵿᴂ,ᴽᴽᵍᵟᵍᴠᵓᵯᴞᵅᵛᵢ,ᴐᴁ ᵺᴉᵸᴵᴶᵄᴪᵷ,ᴌᴠᴗᴚ,ᵟᵺᵳᴝᴉᴰ,ᵹᵥ ᵂᴴ,ᴵ,ᵉᵿ ᴕᵕ,ᴃᴡᴒᵐᴇᴳᵅᵞᴒᴝᴳᴋᴗᵢᵶᵢᵅᴣᴑᵘᵷᵾᴍᴔᴵ,ᴢᴘ,ᴮᵫᴘ,ᵳ,ᴩᵓᴞ