Results 1 to 4 of 4

Thread: QMainWindow modal from non-qt window?

  1. #1
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QMainWindow modal from non-qt window?

    Hello,

    I am trying to make a test QT for the purpose of a Photoshop plugin. For now, i am able to display a QT window (QMainWindow) when the Photoshop plugin is started, but i am having an issue: since i cant tell the QMainWindow who is it's owner, the QMainWindow is not modal. So my question is, is there any way to tell my QMainWindow that another (Which i HAVE the hwnd handle) is it's parent?

    I will probably have the same issue when compiling for mac, but i guess if there is a solution, it will solve both

    Thanks,
    Pierre.

  2. #2
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QMainWindow modal from non-qt window?

    Thanks to this post: http://www.qtcentre.org/forum/f-qt-p...nter-3713.html
    I found it typing different keywords in search function.

    Here is what i did if someone else needs (Photoshop HWND is in "psHwnd"):
    Qt Code:
    1. // This is my QT window:
    2. CWndMainImpl cMainWin;
    3. // This comes from the W32 API:
    4. SetParent((HWND)&cMainWin, psHwnd);
    5. cMainWin.show();
    6. app.connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );
    7. app.exec();
    To copy to clipboard, switch view to plain text mode 

    So, if what i'm doing is good, it would mean that the (HWND) operator of QMainWindow has been overloaded to return a windows handle... Is that it?

    And it seems ok
    Thanks anyway ^^
    Pierre.

    [EDIT] NOT SOLVED:
    After doing this, the window was modal to the "current picture" window in photoshop... But after more testing, when i click any photoshop area, my QT window is finally not modal...
    What am i doing wrong?
    Last edited by hickscorp; 30th March 2007 at 16:21.

  3. #3
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QMainWindow modal from non-qt window?

    Finally solved, it appears that there is no cast overload defined for (HWND) operator on QObject. So the solution is to get the ID of the window, see code following.

    Qt Code:
    1. // This is my QT window:
    2. CWndMainImpl cMainWin;
    3. // This comes from the W32 API:
    4. SetParent((HWND)cMainWin.winId(), psHwnd);
    5. cMainWin.show();
    6. app.connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );
    7. app.exec();
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Aug 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QMainWindow modal from non-qt window?

    Sorry that I reopen this thread again.
    I try this with Photoshop 6.0, and my QMainWindow can show up, and "seem to be"
    modal. I can't access any one of Photoshop's toolboxes and tool bar, and the menu "looks" gray. But when I move my mouse pointer over Photoshop menu, the menu becomes black and accessible. How to make Photoshop to be fully blocked until my QMainWindow is closed?
    Thanks a lot for any hints.

Similar Threads

  1. Independant window in an application
    By titoo in forum Qt Programming
    Replies: 4
    Last Post: 28th February 2007, 11:07
  2. move parent window to the front.
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2007, 08:41
  3. Replies: 3
    Last Post: 23rd July 2006, 18:02
  4. cannot make a main window modal
    By Dark_Tower in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 10:21
  5. Replies: 18
    Last Post: 22nd February 2006, 20:51

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.