Results 1 to 20 of 29

Thread: Need 2 widgets without a parent to comunicate

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2010
    Posts
    23
    Thanks
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Need 2 widgets without a parent to comunicate

    Quote Originally Posted by wysota View Post
    If you do that your app will crash.
    I also have the same idea, only one thread should be the graphical thread. So how can I solve the problem:

    inactive window (hidden) takes the focus instead of the one that is shown the first time? After just a click the shown window it will regain focus and work.
    Thanks
    Ramiro

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Need 2 widgets without a parent to comunicate

    Quote Originally Posted by boblatino View Post
    So how can I solve the problem
    First determine what exactly happens. It could be you are not letting the events be processed and something doesn't know it should release (or gain) focus, i.e. you can't have a focus on a widget which is hidden, so if you do:
    Qt Code:
    1. widget->show();
    2. widget->setFocus(Qt::OtherFocusReason);
    To copy to clipboard, switch view to plain text mode 
    it will probably not work but this might:
    Qt Code:
    1. widget->show();
    2. QCoreApplication::processEvents();
    3. widget->setFocus(Qt::OtherFocusReason);
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    boblatino (27th July 2010)

  4. #3
    Join Date
    Jul 2010
    Posts
    23
    Thanks
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Need 2 widgets without a parent to comunicate

    Quote Originally Posted by wysota View Post
    it will probably not work but this might:
    Qt Code:
    1. widget->show();
    2. QCoreApplication::processEvents();
    3. widget->setFocus(Qt::OtherFocusReason);
    To copy to clipboard, switch view to plain text mode 
    Thanks wysota, it does work now perfectly. I dont know why processEvents is required to avoid sending events to the hidden window but it WORKS! Thanks a lot to all the forum members that have posted here.

    Ramiro

Similar Threads

  1. Replies: 7
    Last Post: 12th January 2011, 22:01
  2. Replies: 1
    Last Post: 22nd April 2010, 14:34
  3. Replies: 2
    Last Post: 22nd April 2010, 11:44
  4. Replies: 3
    Last Post: 29th May 2008, 13:50
  5. initialize child widgets within parent?
    By ucomesdag in forum Newbie
    Replies: 6
    Last Post: 6th June 2006, 08:11

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.