Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Problems importing PySide2.QCharts

Problems importing PySide2.QCharts

Scheduled Pinned Locked Moved Unsolved Qt for Python
pyside2qt for pythonpython
4 Posts 3 Posters 3.4k Views 1 Watching
  • 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.
  • R Offline
    R Offline
    RemcoMusic
    wrote on last edited by RemcoMusic
    #1

    I'm currently using Qt Creator 4.11.0
    Python: 3.8
    PySide 2 version 5.14

    When I'm trying to import QAbstractSeries from QtCharts I am getting an import error.

    # This Python file uses the following encoding: utf-8
    import sys
    
    from PySide2.QtWidgets import QApplication
    from PySide2.QtQml import QQmlApplicationEngine
    from PySide2.QtCore import QObject, qDebug, Signal, Slot, Property
    from PySide2.QtCharts import QAbstractSeries
    
    from audio.__main__ import test
    
    class Main(QObject):
    
        axisChanged = Signal()
    
        def __init__(self):
            QObject.__init__(self)
            self.axisY = 0
    
        testSignal = Signal(QAbstractSeries, arguments=['setYpoints'])
    
        @Property(int, notify=axisChanged)
        def setAxisY(self):
            self.axisY = 150
            return self.axisY
    
        def runOther():
            audioChunk = test()
            print(audioChunk)
    
        @Slot(QAbstractSeries)
        def setYpoints(self, series):
            print(series)
    #        audioChunk = test()
    #        for x in range(len(audioChunk)):
    #            yPoint = audioChunk[x]
    #            self.testSignal.emit(yPoint)
    
    if __name__ == "__main__":
        app = QApplication(sys.argv)
    
        dataToUI = Main()
    
        engine = QQmlApplicationEngine()
        engine.rootContext().setContextProperty("dataToUI", dataToUI)
        engine.load('ApplicationWindow.qml')
        engine.quit.connect(app.quit)
    
        Main.runOther()
    
        sys.exit(app.exec_())
    
    

    Output:

    ImportError: cannot import name 'QAbstractSeries' from 'PySide2.QtCharts' (D:\4. Projecten\WLED_Entertainment\wled\lib\site-packages\PySide2\QtCharts.pyd)

    The path leads to a virtual env that I have created.

    Any help is appreciated, thanks!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Can you import the module itself ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      R 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi and welcome to devnet,

        Can you import the module itself ?

        R Offline
        R Offline
        RemcoMusic
        wrote on last edited by
        #3

        @SGaist said in Problems importing PySide2.QCharts:

        Hi and welcome to devnet,

        Can you import the module itself ?

        Yes I can when I import the module I can compile without any errors.

        When I do:

        import PySide2.QtCharts
        
        #And within the code I use:
        
        QtCharts.QAbstractSeries
        

        Output:

        NameError: name 'QtCharts' is not defined

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          If you want to use it like that, you have to write:

          from PySide2 import QtCharts
          

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2

          • Login

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