Results 1 to 2 of 2

Thread: Mapping from QCompleter::completionModel to QCompleter::model

  1. #1
    Join Date
    Sep 2008
    Posts
    60
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Mapping from QCompleter::completionModel to QCompleter::model

    QCompleter::currentIndex returns QModelIndex of QCompleter::compleitionModel. Would it be possible to map this index to QCompleter::model so that I could access other data associated with the completion string?

    Thanks a lot in advance!

  2. #2
    Join Date
    Sep 2008
    Posts
    60
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mapping from QCompleter::completionModel to QCompleter::model

    I found that the code below works fine and gets the right index:

    Qt Code:
    1. QAbstractProxyModel* proxyModel = qobject_cast<QAbstractProxyModel*>(m_completer->completionModel());
    2. Q_ASSERT(proxyModel != 0);
    3.  
    4. QModelIndex index = proxyModel->mapToSource(m_completer->currentIndex());
    To copy to clipboard, switch view to plain text mode 

    But I haven't seen any documentation saying that QCompleter::completerModel is actually QAbstractProxyModel (naturally it should be). Is there a documented way to map indexes between these two models?

Similar Threads

  1. object-relational mapping support?
    By brcain in forum Qt Programming
    Replies: 18
    Last Post: 28th January 2016, 11:42
  2. Mouse mapping on QTransform problem
    By captchaq in forum Newbie
    Replies: 2
    Last Post: 26th September 2008, 19:11
  3. PyQt - Mapping multiple forms to a database
    By peterjb31 in forum Qt Programming
    Replies: 4
    Last Post: 2nd May 2008, 21:31
  4. mapping manager
    By sreedhar in forum Qt Programming
    Replies: 6
    Last Post: 16th February 2007, 13:48
  5. [itemView] QHeaderView lose mapping at column insertion
    By lauranger in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2006, 18:18

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.