Results 1 to 7 of 7

Thread: console message

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Question console message

    Hi, after nmake (without warning or erros), I launched my app and immediately appear
    a console message:
    Qt Code:
    1. QPaintDevice: Must construct a QApplication before a QPaintDevice
    To copy to clipboard, switch view to plain text mode 
    And app doesn't start. I never see it first.....what happen? thanks...
    Regards

  2. #2
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: console message

    Did you make a QApplication object?
    What's your main() function look like?
    Software Engineer



  3. #3
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: console message

    my app was working first.......
    Qt Code:
    1. #include <qapplication.h>
    2. #include <qsplashscreen.h>
    3. #include "mymainform.h"
    4. int main( int argc, char ** argv )
    5. {
    6. QApplication a( argc, argv );
    7.  
    8. if (!QGLFormat::hasOpenGL())
    9. qFatal("This system has no OpenGL support");
    10.  
    11. QSplashScreen splash(QPixmap::fromMimeSource("splash.jpg"));
    12. splash.show();
    13. splash.message("Loading ... please wait", 0, QColor(255,255,255) );
    14. a.processEvents();
    15.  
    16. myMainForm W;
    17. //W.resize(600,500);
    18. a.setMainWidget(&W);
    19.  
    20. W.show();
    21. a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
    22. splash.finish(&W);
    23. return a.exec();
    24. }
    To copy to clipboard, switch view to plain text mode 
    Regards

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: console message

    Do you have any global variables which might be using a paint device? Global vars are created before main() is called (thus before QApplication object is created).

  5. #5
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: console message

    I think it was this below, a variabile of mainform class but initialized as global....
    is there a way to do this below without that error? (I'd like prog variabile global; thanks
    Qt Code:
    1. //mainform.ui.h
    2. myProgressDialog* prog = new myProgressDialog("Saving file...", "Cancel", 0, 1);
    3. void MainForm::init()
    4. {
    5. ........
    6. }
    To copy to clipboard, switch view to plain text mode 
    Regards

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: console message

    Initialise it after QApplication is created, for example in main().

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

    Default Re: console message

    Quote Originally Posted by mickey
    is there a way to do this below without that error?
    Yes, just initialize it to 0 here and create myProgressDialog after you instantiate QApplication.

    Quote Originally Posted by mickey
    I'd like prog variabile global;
    Global variables are dangerous.

Similar Threads

  1. How to run a console program "silently"?
    By fullmetalcoder in forum Qt Programming
    Replies: 9
    Last Post: 23rd July 2006, 10:03
  2. QPainter in console apps?
    By Funklord in forum Qt Programming
    Replies: 2
    Last Post: 18th April 2006, 14:03
  3. Console apps in Kde Qt
    By peedarp in forum Qt Programming
    Replies: 5
    Last Post: 1st February 2006, 10:43
  4. qt without console window
    By jh in forum Qt Programming
    Replies: 3
    Last Post: 28th January 2006, 20:01
  5. Help sought on console + GUI Integration...
    By mysearch05 in forum Newbie
    Replies: 7
    Last Post: 28th January 2006, 14: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.