Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Unsolved how to insert and dipslay data from dateTimeEdit

    General and Desktop
    python3 pyqt5 mysql
    2
    4
    104
    Loading More Posts
    • 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.
    • L
      lanas last edited by

      i'm using pyqt and python to create an app desktop i create a methods to store time from user but i do not know how to store this time or passe it as variable to display it in qtablewidget

          def ADD_Model(self):
      
                  try:
               
                      cur = connection.cursor()
                      query = "insert into models (date_de_creation) value( %s)"
      
                      value = (
                          self.dateTimeEdit.dateTime()
                      )
                      
                      cur.execute(query, values)
              
                      connection.commit()
                      self.SignupFunction()
                      connection.close()
                      self.labelResult.setText("Data Inserted ")
                  except Exception as e:
                      self.labelResult.setText("Error Inserting Data")
      
      1 Reply Last reply Reply Quote 0
      • V
        VRonin last edited by

        QTableWidgetItem::setData

        Just call tableWidgetItem.setData(Qt.EditRole,self.dateTimeEdit.dateTime())

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        L 1 Reply Last reply Reply Quote 2
        • L
          lanas @VRonin last edited by

          @VRonin sorry but this is for diplaying data right ??

          1 Reply Last reply Reply Quote 0
          • V
            VRonin last edited by

            Yes, Qt.EditRole and Qt.DisplayRole are the same thing in non-customised Qt classes

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply Reply Quote 0
            • First post
              Last post