Results 1 to 10 of 10

Thread: Runtime Error

  1. #1
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Runtime Error

    Hi, I am confused by this problem. When I run my application, a Runtime Error occurs. The following is my main.cpp
    Qt Code:
    1. #include "userDB.h"
    2. #include "manager.h"
    3. #include "user.h"
    4. #include <QApplication>
    5. #include <QTextCodec>
    6. #include <QPixmap>
    7.  
    8. UserDB users; //所有已经注册的用户
    9. User currentUser; //当前用户
    10. QPixmap noDishImage; //comment this line, it works fine
    11.  
    12. int main(int argc, char *argv[])
    13. {
    14. QApplication a(argc, argv);
    15. QTextCodec::setCodecForTr(QTextCodec::codecForName("GB2312"));
    16. Manager w;
    17. w.show();
    18. return a.exec();
    19. }
    To copy to clipboard, switch view to plain text mode 
    User and UserDB are two classes I write.
    Why declaring global variables of my own classes the application works fine, while declaring a blobal variable of the QPixmap leads the application to crash??
    Any ideas appreciated!!

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Runtime Error

    You can not declare any QPaintDevice(inherited by QPixmap,QWidget), without initializing QApplication first.

    change QPixmap to QPixmap*;

    Qt Code:
    1. #include <QApplication>
    2. #include <QPixmap>
    3.  
    4. QPixmap* noDishImage;
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication a(argc, argv);
    9. noDishImage=new QPixmap;
    10. return a.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 

    this should work

  3. The following user says thank you to nish for this useful post:

    sophister (15th June 2009)

  4. #3
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Runtime Error

    btw .. what is that Chinese comment?

  5. #4
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Runtime Error

    Yes, it works fine. And I have refer to the Qt doc.
    谢谢!!

  6. #5
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Runtime Error

    uh, my teammates and I are both Chinese, so we use Chinese to comment our code.
    That two Chinese comments just tell a reader that what the two global variables are used for.

  7. #6
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Runtime Error

    and what u have written in your last post?

    --->谢谢!!<---

  8. #7
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Runtime Error

    It seems you have little knowledge of Chinese?
    Well, 谢谢 means Thank you in English.

  9. #8
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Runtime Error

    i am from India... sadly they dont teach chinese there

    here in taiwan its called Shiey-Shiey

  10. #9
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Runtime Error

    You are from India?? you study in Taiwan now?

  11. #10
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Runtime Error

    I am Indian, i work in Hon Hai Precision Ind. (Foxconn), in Taiwan

Similar Threads

  1. Compile 4.4.0
    By LordQt in forum Installation and Deployment
    Replies: 18
    Last Post: 29th May 2008, 13:43
  2. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  3. Error compiling psql plugin
    By vieraci in forum Installation and Deployment
    Replies: 4
    Last Post: 7th October 2007, 02:49
  4. qt 4.2.2 install on aix
    By try to remember in forum Installation and Deployment
    Replies: 2
    Last Post: 28th March 2007, 12:19
  5. Qt-x11-commercial-src-4.2.0-snapshot-20060824 error
    By DevObject in forum Installation and Deployment
    Replies: 4
    Last Post: 24th August 2006, 23:31

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.