You are not logged in.

1

Tuesday, September 27th 2011, 7:14am

How To Change Combobox

Hi,
I have made a ComboBox and inserted some items lime A, B, AB, D, AC, ABC etc.
Now i want when ever i press A on keyboard it only should highlight A and when i press A followed by B in a quick succession then only it should highlight AB and so on as the nortmal keypress works for search.

My problem is whenever i press A on keyboard it show A but when i again press A it now shows AB that i dont want.
It should only display A.

Also on selection of any key i want to attach some message (not using messagebox) so that user can know about the information attached with particular selection.

I am stuck.

Thank you.

Junior

Professional

  • "Junior" is male

Posts: 1,613

Location: San Antonio, TX USA

Occupation: Senior Secure Systems Engineer

  • Send private message

2

Tuesday, September 27th 2011, 4:18pm

You can use QCompleteron the combo box with setCompleter function. Take a look at the class and examples for more information in usage.

3

Wednesday, September 28th 2011, 1:24pm

Thanks.
I have done it.

i have one more query.

As i type any letter(suppose A) in combobox it display the list of all items starting with that letter(Strating with A), it is ok.
//word list contains all items of combobx
QCompleter *completer = new QCompleter(wordList, this);
completer->completionModel();
completer->setCaseSensitivity(Qt::CaseInsensitive);
comboBox->setCompleter(completer);


But now i want that if i type *(star) it should show all items in the list of combobox.
If i type A*B (A star B) it should show the list of all items starting with A and Ending with B.

any clue or any method that can do it.

Thank you

Junior

Professional

  • "Junior" is male

Posts: 1,613

Location: San Antonio, TX USA

Occupation: Senior Secure Systems Engineer

  • Send private message

4

Wednesday, September 28th 2011, 2:45pm

Your getting away from available reference of data and into analysis of data, this is out of the scope of what QCompleter functionality provides. It doesn't handle wildcards like QRegExp for possible matches. Based on what role settings and/or mode settings you configure, it might be able to get unfiltered results.

This is more of a 'lookup' or 'provide results for' path your wanting now.

pitonyak

Trainee

  • "pitonyak" is male

Posts: 57

Location: Columbus, Ohio, USA

  • Send private message

5

Wednesday, September 28th 2011, 5:54pm

You may be able to write your own solution if you create your own completer class and then over-ride setCompletionPrefix and completionModel, you may be able to write the code required to implement the search yourself. (just a guess, however)

6

Tuesday, October 4th 2011, 12:07pm

Hi,
I am very near to the solution of making ComboBox for customized search.
I have a doubt or may be i am misunderstanding one concept.

when i do...

QCompleter *completer = new QCompleter(wordList, comboBox); //wrodList is QStringList contains some items

Will this search the wordList in comboBox and display the items.

or what will have i to do if i have a worlList(collection of items) and i have to search it into combobox and after matching these items should be pop out.

Thanks