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

how to insert and dipslay data from dateTimeEdit

Scheduled Pinned Locked Moved Unsolved General and Desktop
python3pyqt5mysql
4 Posts 2 Posters 502 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 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
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on 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
      2
      • VRoninV VRonin

        QTableWidgetItem::setData

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

        L Offline
        L Offline
        lanas
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on 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

          • Login

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