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. how to insert and dipslay data from dateTimeEdit
QtWS25 Last Chance

how to insert and dipslay data from dateTimeEdit

Scheduled Pinned Locked Moved Unsolved General and Desktop
python3pyqt5mysql
4 Posts 2 Posters 495 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.
  • L Offline
    L Offline
    lanas
    wrote on 18 May 2022, 10:29 last edited by
    #1

    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
    0
    • V Offline
      V Offline
      VRonin
      wrote on 18 May 2022, 10:48 last edited by
      #2

      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 18 May 2022, 11:09
      2
      • V VRonin
        18 May 2022, 10:48

        QTableWidgetItem::setData

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

        L Offline
        L Offline
        lanas
        wrote on 18 May 2022, 11:09 last edited by
        #3

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

        1 Reply Last reply
        0
        • V Offline
          V Offline
          VRonin
          wrote on 18 May 2022, 11:15 last edited by
          #4

          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
          0

          3/4

          18 May 2022, 11:09

          • Login

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