PDA

View Full Version : QMainWindow modal from non-qt window?



hickscorp
30th March 2007, 17:06
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.

hickscorp
30th March 2007, 17:17
Thanks to this post: http://www.qtcentre.org/forum/f-qt-programming-2/t-convert-windows-hwnd-to-qwidget-pointer-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"):

// This is my QT window:
CWndMainImpl cMainWin;
// This comes from the W32 API:
SetParent((HWND)&cMainWin, psHwnd);
cMainWin.show();
app.connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );
app.exec();

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?

hickscorp
31st March 2007, 00:10
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.


// This is my QT window:
CWndMainImpl cMainWin;
// This comes from the W32 API:
SetParent((HWND)cMainWin.winId(), psHwnd);
cMainWin.show();
app.connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );
app.exec();

trytry
21st November 2008, 10:10
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.