PDA

View Full Version : 100% CPU load after displaying a QDialog...



hickscorp
3rd April 2007, 02:30
Hello,

I am actually starting a QMainWindow from a non-QT application via it's plugins system (Photoshop). The code which starts the QMainWindow is like follows:


// Initialize the QT engine.
int iArgC = 0;
static QApplication app (iArgC, NULL);

CWndMainImpl cMainWin((HWND)((PlatformData*)gFilterRecord->platformData)->hwnd);
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );
cMainWin.show();
app.exec();
I am doing a static QApplication, because the QT plugin can be started severals times without Photoshop restarts (E.g.: If the user wants to process different pictures).
[EDIT:] (HWND)((PlatformData*)gFilterRecord->platformData)->hwnd is a pointer to the main Photoshop's window handle.

Then when the user clicks on some of the CWndMainImpl buttons, i do like this:


setEnabled(false);
CDlgSettingsImpl cSettings(this);
if (cSettings.exec())
close();
setEnabled(true);
This displays a QDialog subclassed object.
My problem is, when the QDialog opens, the CPU goes to 100% (Actually, the 1st virtual proc of my hyper-threaded system goes to 50%)...
What am i doing wrong here? oO

Another thing (With or without it, the CPU problem is there, it's another question), after the CDlgSettingsImpl is started (And from it's constructor), i call another QMainWindow like this:


CDlgPreviewImpl* pPreview = new CDlgPreviewImpl(this);
pPreview->show();
What i want, is another window to be present at the same time when CDlgSettingsImpl is started (The window will hold the preview of the processed picture), but i dont want a "blocking" QDialog since it requires real-time communication with the caller object (CDlgSettingsImpl). Is my method the good one to do what i described?

Thanks a lot for your advices.
Pierre.

hickscorp
3rd April 2007, 03:10
It seems i just have found what was going wrong.
The "100% CPU QDialog" was containing a custom widget i previously designed. This widget was overloading the paint() method to draw it's own content. The problem was, i was calling setUpdatesEnabled(false); at the begining and setUpdatesEnabled(true); as suggested in the manual regarding to big updates... Now my CPU felt back to 0% :)

Regarding to the last question of this post, if you have suggestions i'm listening :)

Thanks anyway, i hope this will help.
Pierre.