I know this has been answered plenty of times, but since I'm totally new to pyqt/python (only been trying it for a week now) I can't seem to implement any of those solutions in my code.
import sys
from PyQt4.QtSql import *
from PyQt4 import QtCore, QtGui, uic
app = QtGui.QApplication(sys.argv)
class TestApp(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
self.ui = uic.loadUi("C:\Python34\Lib\site-packages\PyQt4\BazaPodataka\database_GUI.ui")
self.ui.show()
db = QSqlDatabase.addDatabase("QPSQL")
db.setHostName("localhost")
db.setDatabaseName("BP Za bolnicu")
db.setUserName("postgres")
db.setPassword("zanoktica")
db.setPort(5432)
ok = db.open()
if ok:
print("Connected to database")
else:
print("Error connecting to database")
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
win = TestApp()
sys.exit(app.exec_())
I know my code is a mess, I'm trying to figure out multiple things at once. I made a GUI in Qt designer, and now I'm trying to implement it in my main code so that I can change it as I please, and then just implement the newer version.