Results 1 to 10 of 10

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

Hybrid View

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

    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)

  3. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,332
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    317
    Thanked 871 Times in 858 Posts

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

    No, but the modified QCompleter is more general than that
    Point taken.

    In a bit of circular logic, I suppose you could give a table model-based completer to a line-edit based delegate in a QTableView that uses the same model as the view to emulate what happens when editing a real spreadsheet - as you type a new entry, it shows completed entries based on what has already been entered into the column.
    Last edited by d_stranz; 24th January 2016 at 18:25.

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.