Results 1 to 3 of 3

Thread: QLineEdit + QCompleter: returnPressed signal

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2010
    Posts
    11
    Thanks
    3
    Qt products
    Platforms
    MacOS X Unix/X11 Windows

    Default QLineEdit + QCompleter: returnPressed signal

    hi,

    i've got a really annoying problem with QLineEdit AND QCompleter. i develop with pyqt4 but i think it does not make any difference in this case.
    my situation:

    i build a QDialog with two QLineEdit elements. both are connected to a (different) QCompleter instance. i customized the behaviour of the QComleter to enable inline completion, after a defined separator has been entered.
    for this purpose i connect my handler to the "activated(QString)" signal of the completer. this is emitted, when a suggested value of the QCompleter has been selected.
    when this signal is emitted - i manually write the new content to the lineEdit object.

    whenever i choose a suggestion of the completer by hitting enter, the "returnPressed()" signal of the QLineEdit gets fired. just after the execution of the connected slot, the signal "activated(QString)" is emitted.
    the problem is, i have a custom slot connected to the returnPressed() signal of the lineEdit instances. these should just come into action if there was an eplicit "hit enter" just in the lineedit and not in the completer.

    has anybody an idea how to ignore the returnPressed() signal when just choosing a suggestion from the completer?
    why is there even a returnPressed() signal? the completer uses a QListView afaik - and this does not emit a returnPressed() signal.

    i would really appreciate your help!

    thnx - chris

    here is an example, of what i do in my code:

    -> it is python code - but its easily understandable

    Qt Code:
    1. # connect the activated signal to do custom handling
    2. self.connect(self.__completer, QtCore.SIGNAL("activated(QString)"), self.__text_activated)
    3.  
    4. # connect returnpressed() signal of the lineedit
    5. self.connect(self.__first_line, QtCore.SIGNAL("returnPressed()"), self.__handle_first_line_enter)
    6. self.connect(self.__second_line, QtCore.SIGNAL("returnPressed()"), self.__handle_second_line_enter)
    To copy to clipboard, switch view to plain text mode 

    "__handle_first_line_enter()" or "__handle_second_line_enter()" are always called befor the "__text_activated()"
    this is, what it is ment to get rid of
    Last edited by wysota; 21st September 2010 at 12:50.

Similar Threads

  1. Replies: 4
    Last Post: 21st January 2011, 01:27
  2. How get signal returnPressed in QTextEdit
    By Roszko in forum Qt Programming
    Replies: 13
    Last Post: 30th December 2009, 09:59
  3. Replies: 1
    Last Post: 12th October 2008, 08:21
  4. QSpinBox and returnPressed() Signal
    By BeS in forum Newbie
    Replies: 2
    Last Post: 14th October 2006, 19:23
  5. QLineedit::returnPressed() closes dialog?
    By geranol in forum Newbie
    Replies: 2
    Last Post: 6th January 2006, 10:18

Tags for this Thread

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.