Results 1 to 10 of 10

Thread: Can a QCompleter emit a signal of index of position of its inside list, by clicking?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #9
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Can a QCompleter emit a signal of index of position of its inside list, by clicki

    Quote Originally Posted by ChrisW67 View Post
    Unfortunately the row number is in the filtered list not the full model. The completer is using a proxy model internally. Unfortunately that model is undocumented/private or we might be able to use QAbstractProxyModel::mapToSource().
    Interesting, didn't know that.

    So alternatively one could do something like

    Qt Code:
    1. QModelIndex baseIndex = index;
    2. while (QAbstractProxyModel *proxy = qobject_cast<QAbstractProxyModel*>(baseIndex.model()) {
    3. baseIndex = proxy->mapToSource(baseIndex);
    4. }
    5. int row = baseIndex.row();
    To copy to clipboard, switch view to plain text mode 

    But using a completer subclass is definitely cleaner.

    Cheers,
    _

  2. The following user says thank you to anda_skoa for this useful post:

    Alex22 (25th January 2016)

Similar Threads

  1. Seems that my emit doesn't emit the signal
    By roseicollis in forum Newbie
    Replies: 2
    Last Post: 19th January 2015, 16:05
  2. Replies: 1
    Last Post: 12th January 2011, 22:40
  3. Replies: 0
    Last Post: 4th April 2010, 17:42
  4. emit a signal from inside a callback routine
    By franco.amato in forum Qt Programming
    Replies: 20
    Last Post: 21st January 2010, 18:05
  5. eventFilter and clicking inside QSpinBox
    By T4ng10r in forum Qt Programming
    Replies: 2
    Last Post: 6th March 2007, 21:02

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
  •  
Qt is a trademark of The Qt Company.