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 make my button "Insert data" loop because when i clicked it once the button state will be disable how to make it like infinite loop button so i can clicked anytime i want

How to make my button "Insert data" loop because when i clicked it once the button state will be disable how to make it like infinite loop button so i can clicked anytime i want

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 918 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    import sys
    import os
    from PyQt4 import QtGui, QtCore
    from PyQt4.QtGui import *
    from PyQt4.QtCore import *
    from PyQt4.QtCore import SIGNAL
    from PyQt4.QtSql import *

    class Window(QtGui.QMainWindow):

    def __init__(self):
        super(Window,self).__init__()
        self.setGeometry(50,50,0,0)
        self.setFixedSize(1250,700)
        self.setWindowTitle("IMS Delta EarthMoving Incorporated")
        self.setWindowIcon(QtGui.QIcon('Pictures/delta.png'))
        self.home()
        self.database()
    
    def home(self):
        btn = QtGui.QPushButton("Insert data",self)
        btn.isChecked()
        btn.clicked.connect(self.import_application)
    
        btn.resize(btn.minimumSizeHint())
        btn.move(0,0)
    
        self.show()
    
    def import_application(self):
        choice = QtGui.QMessageBox.question(self,'IMS',"Check Query before Submiting",QtGui.QMessageBox.Ok)
        if choice == QtGui.QMessageBox.Ok:
            import QtInputDelta
    
        
    def database(self): #Table data view
        table 	= QTableWidget(self)
        db 	= QSqlDatabase.addDatabase("QMYSQL")
    
        db.setHostName("localhost")
        db.setDatabaseName("test")
        db.setUserName("root")
        db.setPassword("admingelo")
    
        if (db.open()==False):     
            QMessageBox.critical(None, "Database Error",
    		    db.lastError().text())   
    		    
        query = QSqlQuery ("SELECT * FROM sfo")   
    
        table.setColumnCount(query.record().count())
        table.setRowCount(query.size())
    
        index=0
        while (query.next()):
                table.setItem(index,0,QTableWidgetItem(query.value(0).toString()))
                table.setItem(index,1,QTableWidgetItem(query.value(1).toString()))
                table.setItem(index,2,QTableWidgetItem(query.value(2).toString()))
                table.setItem(index,3,QTableWidgetItem(query.value(3).toString()))
                table.setItem(index,4,QTableWidgetItem(query.value(4).toString()))
                table.setItem(index,5,QTableWidgetItem(query.value(5).toString()))
                index = index+1
    
        table.show()
        table.resize(1230,615)
        table.move(10,75)
    

    def run():
    app = QtGui.QApplication(sys.argv)
    GUI = Window()
    sys.exit(app.exec_())
    run()

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

      Hi,

      Can you explain exactly what you are trying to achieve ?

      By the way, why not use a QTableView with a QSqlTableModel ?

      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
      3
      • SGaistS SGaist

        Hi,

        Can you explain exactly what you are trying to achieve ?

        By the way, why not use a QTableView with a QSqlTableModel ?

        ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        @SGaist can you give an example of QSqlTableModel?

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

          Seriously: did you even take the time to read the documentation I linked to ? At the end of the detailed description there are several links to examples using that class.

          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
          3
          • SGaistS SGaist

            Seriously: did you even take the time to read the documentation I linked to ? At the end of the detailed description there are several links to examples using that class.

            ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            @SGaist sorry thank you for the late reply thank you for helping me

            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