Results 1 to 2 of 2

Thread: problem with focusEvent

  1. #1
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    116
    Thanked 42 Times in 41 Posts

    Default problem with focusEvent

    hi friends,

    my task is to show a list widget when user press or click on a lineEdit() ...
    i made a small class popWidget derived from QListWidget and using the event filter on lineEdit i am showing the popWidget using show()...

    Qt Code:
    1. eventFilter( QObject *obj, QEvent *ev )
    2. {
    3. if (obj == _hwListView)
    4. {
    5. if (ev->type() == QEvent::FocusIn)
    6. {
    7. _hwListPop->show();
    8. _hwListPop->setFocus(Qt::PopupFocusReason);
    9. return true;
    10. }else
    11. return false;
    12. }
    To copy to clipboard, switch view to plain text mode 
    then comes the problem with hide() when the user press somewhere in the mainwindow ..


    i reimplemented focusOutEvent() on popWidget to hide() it when it lost its focus ..
    Qt Code:
    1. PopWidget::focusOutEvent(QFocusEvent *event)
    2. {
    3. this->hide();
    4. }
    To copy to clipboard, switch view to plain text mode 


    actually that lineEdit is a part of the object say subWindow of mainWindow so when i press any where in subWindow i can manage to hide the popWidget but not in the mainWindow ..

    how can i send the particular event to the mainWindow ..?

    please help me ...
    "Behind every great fortune lies a crime" - Balzac

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: problem with focusEvent

    It all sounds that you could use a QCompleter and let Qt do all the stuff for displaying hiding etc.

  3. The following user says thank you to Lykurg for this useful post:

    wagmare (16th August 2010)

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.