Results 1 to 9 of 9

Thread: QtSingleApplication

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: QtSingleApplication

    Did you try to invoke the QWidget::activateWindow() method (together with raise())?

  2. #2
    Join Date
    Feb 2006
    Posts
    22
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3

    Default Re: QtSingleApplication

    Yes, I see I failed to copy&paste all the things I tried. Here they are:
    activateWindow();
    setFocus( Qt::OtherFocusReason );
    show();
    setWindowState( Qt::WindowActive );
    update();
    repaint();
    setVisible( true );
    raise();

    As you can see, I was getting frustrated/desperate/confused ...

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: QtSingleApplication

    According to the docs, you should call QWidget::setActiveWindow() (or rather QApplication::setActiveWindow() as it should be written):
    void QtSingleApplication::activateMainWidget () [virtual slot]
    Calls QWidget::setActiveWindow() on this application's mainWidget(). This function does nothing if no main widget has been set.
    This slot is typically connected to the messageReceived() signal.
    See also messageReceived().
    So such combo:
    Qt Code:
    1. show();
    2. raise();
    3. activateWindow();
    To copy to clipboard, switch view to plain text mode 
    should be enough. Maybe somebody else knows the answer, but you can always try the OS specific functions as the last resort.

  4. #4
    Join Date
    Feb 2006
    Posts
    22
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3

    Default Re: QtSingleApplication

    Thank you for your help, jacek, and thank you for redirecting me back to the doc. I had placed the doc aside a while back after many failed attempts and was just trying things by brute force and trial/error.

    I need to go back and re-think this from the beginning. The doc mentions setMainWidget() and its relation to activateMainWidget(). Since setMainWidget() was abandoned from Qt3 to Qt4 (I am using Qt4) I was trying to do the equivalent with QMainWindow, setCentralWidget(), and such.

    If/When I figure this out, I will post the solution.

    Other input/thoughts/suggestions still welcome ...

Similar Threads

  1. Replies: 10
    Last Post: 11th June 2007, 09:18
  2. QtSingleApplication and Qr 4.2.1
    By Lele in forum Qt Programming
    Replies: 1
    Last Post: 23rd October 2006, 10:41

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.