Important: Please read the Qt Code of Conduct -

pyside2 qtcharts updating its self as month elapse

  • I am trying to make a chart where every first of each month the chart updates its self if anyone who has a solution or an idea i would be so grateful.

     def create_bar(self):
         # The QBarSet class represents a set of bars in the bar chart.
         # It groups several bars into a bar set
         set0 = QtCharts.QBarSet("markup")
         set1 = QtCharts.QBarSet("liabil")
         # set data
         # initial data = current sales and expenses
         if ==
              set0 << self.total_sales()
              set1 << self.total_expenses()
              set0 << self.total_sales()
              set1 << self.total_expenses()
         # load data to chart
          series = QtCharts.QBarSeries()
            # initialize chart
            chart = QtCharts.QChart()
            categories ='%b')
            axis = QtCharts.QCategoryAxis()
            axisY = QtCharts.QValueAxis()
            axis.append(str(categories), 0)
            chart.addAxis(axisY, QtCore.Qt.AlignLeft)
            axisY.setRange(0, 10000)
            chart.setAxisX(axis, series)
   = QtWidgets.QVBoxLayout(self)
   = QtWidgets.QVBoxLayout(self.ui.widget_2)
  , 0, 0, 0)
            self.chartview = QtCharts.QChartView(chart)
            self.chartview.setContentsMargins(0, 0, 0, 0)

  • @erico

    Where is your question?

    @erico said in pyside2 qtcharts updating its self as month elapse:

    if the current month is over the chart updates

    Cant you just replace this statement with "every first of each month"? When it is the first of any month, the last month is most likely over ;-)


    Since you updated your question... I meant this literally. You could check if == 1.

    What kind of program is this? Should it keep on running all the time or do you want to update, when you start your program?

  • @Pl45m4 it should keep on updating its self

  • @erico
    Update itself when/in response to what? You have to clarify what you are looking to do.

Log in to reply