Results 1 to 2 of 2

Thread: 100% CPU load after displaying a QDialog...

  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 100% CPU load after displaying a QDialog...

    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:
    Qt Code:
    1. // Initialize the QT engine.
    2. int iArgC = 0;
    3. static QApplication app (iArgC, NULL);
    4.  
    5. CWndMainImpl cMainWin((HWND)((PlatformData*)gFilterRecord->platformData)->hwnd);
    6. app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );
    7. cMainWin.show();
    8. app.exec();
    To copy to clipboard, switch view to plain text mode 
    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:
    Qt Code:
    1. setEnabled(false);
    2. CDlgSettingsImpl cSettings(this);
    3. if (cSettings.exec())
    4. close();
    5. setEnabled(true);
    To copy to clipboard, switch view to plain text mode 
    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:
    Qt Code:
    1. CDlgPreviewImpl* pPreview = new CDlgPreviewImpl(this);
    2. pPreview->show();
    To copy to clipboard, switch view to plain text mode 
    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.
    Last edited by hickscorp; 3rd April 2007 at 01:34.

  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: 100% CPU load after displaying a QDialog...

    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.

Similar Threads

  1. Resizing a QDialog to the content size
    By Nyphel in forum Qt Programming
    Replies: 8
    Last Post: 15th March 2007, 08:16

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.