Results 1 to 4 of 4

Thread: ComboBox Completer Index Problem

  1. #1
    Join Date
    Mar 2009
    Posts
    9
    Thanks
    1

    Exclamation ComboBox Completer Index Problem

    When i choose something in completer, combobox index does not change. It's changing only when i press enter key. But i want to change index of combo in completer by choosing mouse from popup. How i can do it? Help

    Qt Code:
    1. QComboBox *cb=new QComboBox();
    2. cb->setModel(this->productModel);
    3. cb->setModelColumn(1);
    4. cb->setEditable(true);
    5. cb->setAutoCompletion(true);
    6. cb->setAutoCompletionCaseSensitivity(Qt::CaseInsensitive);
    To copy to clipboard, switch view to plain text mode 
    Last edited by majatu; 4th June 2009 at 14:07.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: ComboBox Completer Index Problem

    Connect to the activated() signal of the completer and set the appropriate index of the combobox as the current one.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    majatu (7th June 2009)

  4. #3
    Join Date
    Mar 2009
    Posts
    9
    Thanks
    1

    Default Re: ComboBox Completer Index Problem

    Quote Originally Posted by wysota View Post
    Connect to the activated() signal of the completer and set the appropriate index of the combobox as the current one.
    thanks for reply, but activated method of completer content index of model, but combobox have setIndex for row only

  5. #4
    Join Date
    Mar 2009
    Posts
    9
    Thanks
    1

    Default Re: ComboBox Completer Index Problem

    solved:

    if interesting

    Qt Code:
    1. void EventDialog::popUpIndex(QModelIndex s)
    2. {
    3. QCompleter * cl = qobject_cast<QCompleter * >(sender());
    4. QComboBox * cb = qobject_cast<QComboBox * >(sender()->parent());
    5.  
    6. int completer_id=cl->completionModel()->data(cl->completionModel()->index(s.row(),0)).toInt();
    7.  
    8. QModelIndexList indexList = cb->model()->match(cb->model()->index(0,0), Qt::DisplayRole, completer_id, 1, Qt::MatchExactly);
    9. if(indexList.count())
    10. {
    11. QModelIndex index=indexList.first();
    12. cb->setCurrentIndex(index.row());
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Problem in displaying the ComboBox list
    By raghvendramisra in forum Qt Tools
    Replies: 4
    Last Post: 28th February 2008, 13:25
  2. [Qt 4.3.1]A problem with combobox style
    By Tamara in forum Qt Programming
    Replies: 3
    Last Post: 19th September 2007, 10:49
  3. color comboBox problem
    By chguy2 in forum Qt Programming
    Replies: 2
    Last Post: 22nd April 2007, 09:57
  4. Problem with a combobox
    By Tindor in forum Qt Programming
    Replies: 2
    Last Post: 22nd November 2006, 19:18
  5. Problem with index in a QTreeView
    By hubert_p in forum Qt Programming
    Replies: 4
    Last Post: 22nd October 2006, 15:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.