Results 1 to 16 of 16

Thread: must construct QApplication before constructing QPaintDevice

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    45
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default must construct QApplication before constructing QPaintDevice

    Hi,

    I am making a simple testproject and I get this message when I run the project wich compiled fine.

    Must construct a QApplication before a QPaintDevice

    In the code you can see that I construct a QApplication before anything else.

    ????

    regix Archief.tar.bz2

  2. #2
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: must construct QApplication before constructing QPaintDevice

    You have a static ImageToHtml object (last line of testcodec.cpp). Static objects are created before the main() function is entered. Since ImageToHtml is a widget (a paint device), it gets created before QApplication.

    That last line is useless. Is it a typo?

  3. #3
    Join Date
    Jan 2006
    Posts
    45
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: must construct QApplication before constructing QPaintDevice

    Thanks,

    I must have been blind to not see that.
    Probably it was not visible in the editor I was using.
    thanks anyway.

    regix

  4. #4
    Join Date
    Feb 2007
    Posts
    81
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: must construct QApplication before constructing QPaintDevice

    Is there anything else that can cause this error?

    I am using this bash script (http://qtcentre.org/forum/f-qt-progr...ighlight=qtxml) which embeds 4 Qt frameworks into the app and makes it into a dmg file, and once I do that, I receive this error. Before I embed the frameworks I do not get this error.

    I can't seem to find any other reason why it would be caused. If anyone has any ideas let me know.
    thanks for the help,
    dave

  5. #5
    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: must construct QApplication before constructing QPaintDevice

    You surely have some global object somewhere which is created before QApplication.

  6. #6
    Join Date
    Feb 2007
    Posts
    81
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: must construct QApplication before constructing QPaintDevice

    so that means that it must be outside of any class definition? I really can't find it. Why would it work before embedding the frameworks though?

  7. #7
    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: must construct QApplication before constructing QPaintDevice

    I have no idea. I don't even know why you use that script. AFAIK Qt can create bundles by itself.

  8. #8
    Join Date
    Feb 2007
    Posts
    81
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: must construct QApplication before constructing QPaintDevice

    I've never seen anything on the Qt documentation about making dmg's. I found the script here originally:

    http://qtnode.net/wiki/Distributing_Mac_Qt_applications

    The script even says the guy who created it doesn't use it anymore, but I've never found a better way to do it. Do you have any suggestions. All I really need it for is to embed the QtCore, QtXml, QtOpenGL, and QtGui frameworks into my .app.

  9. #9
    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: must construct QApplication before constructing QPaintDevice

    http://doc.trolltech.com/latest/deployment-mac.html

    Anyway that's not the issue here. There is something wrong with your code.

  10. #10
    Join Date
    Feb 2007
    Posts
    81
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: must construct QApplication before constructing QPaintDevice

    I really don't see anything wrong with it. Will it definitely have the word static in it? The code is way too large to post up here, so I guess I'll just keep looking. I don't understand why it works with the absolute paths to the libraries, but not with the relative paths.

    One thing I noticed that this script does that seems strange is in the results of

    otool -L

    before the script
    Qt Code:
    1. /Library/Frameworks/Python.framework/Versions/2.5/Python (compatibility version 2.5.0, current version 2.5.0)
    2. /Library/Frameworks/3DconnexionClient.framework/Versions/A/3DconnexionClient (compatibility version 1.0.0, current version 1.0.0)
    3. /usr/local/Trolltech/Qt-4.3.0beta/lib/QtXml.framework/Versions/4/QtXml (compatibility version 4.3.0, current version 4.3.0)
    4. /usr/local/Trolltech/Qt-4.3.0beta/lib/QtOpenGL.framework/Versions/4/QtOpenGL (compatibility version 4.3.0, current version 4.3.0)
    5. /System/Library/Frameworks/QuickTime.framework/Versions/A/QuickTime (compatibility version 1.0.0, current version 12.0.0)
    6. /usr/local/Trolltech/Qt-4.3.0beta/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.3.0, current version 4.3.0)
    7. /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 128.0.0)
    8. /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 824.42.0)
    9. /usr/local/Trolltech/Qt-4.3.0beta/lib/QtCore.framework/Versions/4/QtCore (compatibility version 4.3.0, current version 4.3.0)
    10. /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
    11. /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.6)
    12. /usr/lib/libiconv.2.dylib (compatibility version 5.0.0, current version 5.0.0)
    13. /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 22.0.0)
    14. /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
    15. /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
    16. /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
    17. /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
    To copy to clipboard, switch view to plain text mode 

    after the script
    Qt Code:
    1. /Library/Frameworks/Python.framework/Versions/2.5/Python (compatibility version 2.5.0, current version 2.5.0)
    2. /Library/Frameworks/3DconnexionClient.framework/Versions/A/3DconnexionClient (compatibility version 1.0.0, current version 1.0.0)
    3. @executable_path/../Frameworks/QtXml.framework/Versions/4/QtXml (compatibility version 4.3.0, current version 4.3.0)
    4. @executable_path/../Frameworks/QtOpenGL.framework/Versions/4/QtOpenGL (compatibility version 4.3.0, current version 4.3.0)
    5. /System/Library/Frameworks/QuickTime.framework/Versions/A/QuickTime (compatibility version 1.0.0, current version 12.0.0)
    6. @executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui (compatibility version 4.3.0, current version 4.3.0)
    7. /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 128.0.0)
    8. /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 824.42.0)
    9. @executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore (compatibility version 4.3.0, current version 4.3.0)
    10. /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
    11. /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.6)
    12. /usr/lib/libiconv.2.dylib (compatibility version 5.0.0, current version 5.0.0)
    13. /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 22.0.0)
    14. /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
    15. /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
    16. /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
    17. /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
    To copy to clipboard, switch view to plain text mode 

    saying @executable_path seems wrong, but I don't really know enough about it to know whether that's right or not.

  11. #11
    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: must construct QApplication before constructing QPaintDevice

    No, the object doesn't have to be static. It's enough if it's global. Maybe your Qt installation is somehow broken?

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.