Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt project using matplotlib fails with "cannot create a QWidget without QApplication error
Forum Updated to NodeBB v4.3 + New Features

Qt project using matplotlib fails with "cannot create a QWidget without QApplication error

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 667 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    istlota101
    wrote on last edited by
    #1

    Re: QWidget: Cannot create a QWidget without QApplication - OpenCV imshow() 2.4.13 ?

    I figure someone else will eventually run into this, and I am just documenting whazzup. Those of us who are into scientific projects frequently need to use matplotlib to create plots, but matplotlib is a python library. Which is okay if you don't mind using Qt for Python, but for a few years now I have used C++ as my language of choice. Instead of using Qt for Python, it is not that difficult to take advantage of
    python's built-in Python/C API to embed a python interpreter in your C++ code. And, since matplotlib can save plots as PNG files, you can then present them in QML Images. But, at some version of Qt, my previous Way of embedding matplotlib python code in my Qt/QML apps began failing with a "cannot create QWIdget without QApplication" error. The now closed topic which this topic references pointed out that the fix for this error is to add "widgets" to the QT += statement in your qmake .pro file, and to use QApplication in your main.cpp. If someone wishes, I'll put up an example of what I am talking about on github, but it might not be "Hello World" -esque due to my multi-lingual coding style which mixes C++, python, QML, javascript, OpenCL, GLSL, and whatever else I need at the time.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved