Results 1 to 4 of 4

Thread: focusOut- event issue

  1. #1
    Join Date
    Apr 2006
    Location
    Narvik, NORWAY
    Posts
    9
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Windows

    Question focusOut- event issue

    My problem is:


    I want to catch focus-out event from some QDateEdits
    This works fine if one of their siblings, which are not QDateEdits, is the next who gets focus.
    But if the focus is handed over to some other widget my program ends up in a loop where
    the QDateEdit who lost focus seems to go on loosing focus forever.


    This is essensially how my eventFilter looks...........


    bool MyWidget::eventFilter( QObject *obj, QEvent *ev )
    {

    if(obj == myDateEdit ){

    if(ev->type() == QEvent::FocusOut){

    bool ok = true;

    if(<some condotion>) ok = false;

    if(!ok) QMessageBox::information(0, "Message", "Condition is met","Ok");

    ((QDateEdit*)obj)->clearFocus();
    return true;
    } else return false;
    }
    else return QWidget::eventFilter(obj,ev);
    }


    How can I detect the situation where focus is handed over to some widget that is not a sibling?

  2. #2
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: focusOut- event issue

    I dont know is it eactly what you whant but try reinplement boolQWidget::focusNextPrevChild ( bool next ) [virtual protected]
    for your QDateEdit.
    a life without programming is like an empty bottle

  3. #3
    Join Date
    Apr 2006
    Location
    Narvik, NORWAY
    Posts
    9
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Windows

    Cool Re: focusOut- event issue

    Quote Originally Posted by zlatko
    I dont know is it eactly what you whant but try reinplement boolQWidget::focusNextPrevChild ( bool next ) [virtual protected]
    for your QDateEdit.

    Thanks. I just made a call to focusNextPrevChild(..), and my problem whas solved, almost.

    What remains is: when a sibling gets focus, one focus-out event occurs
    when some other widget gets focus, two focus_out events occurs.

    If you can explain the reason for that, it would help me solve another problem.

  4. #4
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: focusOut- event issue

    Quote Originally Posted by gunhelstr
    when some other widget gets focus, two focus_out events occurs.
    For what widget?
    a life without programming is like an empty bottle

Similar Threads

  1. Replies: 4
    Last Post: 19th February 2009, 11:10
  2. Custom event gets not propagated to the top level widget
    By nightghost in forum Qt Programming
    Replies: 0
    Last Post: 29th January 2009, 09:06
  3. Event propagation direction
    By spraff in forum Qt Programming
    Replies: 0
    Last Post: 6th December 2008, 21:03
  4. Qt event queue overloading?
    By gct in forum Qt Programming
    Replies: 3
    Last Post: 17th March 2008, 18:39
  5. Workload in a QThread blocks main application's event loop ?
    By 0xBulbizarre in forum Qt Programming
    Replies: 14
    Last Post: 9th April 2006, 21:55

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.