Unsolved QtCharts in Qt Designer
-
Hi everybody,
again I am facing a problem with adding an external element to Qt Designer via promoting basic classes.
Now I have a problem with promotingQtChart
...
May be this is just some problem with my understanding of how the promotion works, but I really wasn't able to find any clear instructions on how to do it. May be I am missing some important insight.
With my setup I get an error:ModuleNotFoundError: No module named 'QtCharts'
Below some basic code example, the according .ui file and a screenshot of installed packages (to assure you that PyQt5 and PyQtChart do have the the same version)
When trying to promote the
GraphicsView
class I was referring to the following answer on stackoverflow: https://stackoverflow.com/a/48363007/14326459 (Option 1)
The only thing I didn't do is to addQT += charts
in the .pro, because I don't quite get what is meant by that.import sys, os from PyQt5.uic import loadUi from PyQt5.QtWidgets import QApplication, QMainWindow CURRENT_DIRECTORY = os.path.dirname(os.path.realpath(__file__)) class MainWindow(QMainWindow): def __init__(self, parent=None): super(MainWindow, self).__init__(parent) path = os.path.join(CURRENT_DIRECTORY, 'GUI', 'main.ui') self.w = loadUi(path) self.w.show() if __name__ == '__main__': app = QApplication(sys.argv) w = MainWindow() sys.exit(app.exec_())
<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MainWindow</class> <widget class="QMainWindow" name="MainWindow"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>670</width> <height>403</height> </rect> </property> <property name="windowTitle"> <string>MainWindow</string> </property> <widget class="QWidget" name="centralwidget"> <widget class="QChartView" name="graphicsView"> <property name="geometry"> <rect> <x>90</x> <y>60</y> <width>256</width> <height>192</height> </rect> </property> </widget> </widget> <widget class="QMenuBar" name="menubar"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>670</width> <height>21</height> </rect> </property> </widget> <widget class="QStatusBar" name="statusbar"/> </widget> <customwidgets> <customwidget> <class>QChartView</class> <extends>QGraphicsView</extends> <header>QtCharts</header> </customwidget> </customwidgets> <resources/> <connections/> <buttongroups> <buttongroup name="abc"/> </buttongroups> </ui>
Thanks a lot in advance for all your answers!