Results 1 to 2 of 2

Thread: Qline edit focusIn event

  1. #1
    Join Date
    Jan 2011
    Location
    Sri Lanaka
    Posts
    64
    Thanks
    39
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Post Qline edit focusIn event

    hello
    How can i catch a QlineEdit focusIn event from the main window..
    without subclassing QlineEdit ...

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Qline edit focusIn event

    You can create and install an event filter, and emit a signal in there, something like this

    Qt Code:
    1. class FocusInSignal: public QObject
    2. {
    3. Q_OBJECT
    4. ...
    5. signals:
    6. void focusIn(void);
    7.  
    8. protected:
    9. bool FocusInSignal::eventFilter(QObject *obj, QEvent *event)
    10. {
    11. if (event->type() == QEvent::FocusIn) {
    12. emit focusIn();
    13. return true;
    14. } else {
    15. // standard event processing
    16. return QObject::eventFilter(obj, event);
    17. }
    18. }
    19. }
    20.  
    21. // in the main window
    22. FocusInSignal* filter = new filter(this);
    23. connect(filter, SIGNAL(focusIn()), this, SLOT(lineEditGotFucus()));
    24. lineEdit->installFilter(filter);
    25.  
    26. void MainWindow::lineEditGotFucus(void)
    27. {
    28. // processes
    29. }
    To copy to clipboard, switch view to plain text mode 

  3. The following 2 users say thank you to Santosh Reddy for this useful post:

    deepal_de (9th June 2011), evgeniy (21st January 2014)

Similar Threads

  1. Selecting a QLine
    By Paul Drummond in forum Qt Programming
    Replies: 6
    Last Post: 2nd September 2015, 16:30
  2. Is there focus event for line edit?
    By vjsharma_30 in forum Qt Programming
    Replies: 6
    Last Post: 19th February 2010, 20:12
  3. Can I add a QLine
    By Danster in forum Qt Programming
    Replies: 2
    Last Post: 14th August 2009, 18:37
  4. Qt text edit paint event
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 27th October 2007, 18:13
  5. Signal problem in Qline Edit
    By awalesminfo in forum Newbie
    Replies: 1
    Last Post: 3rd April 2006, 09:13

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.