Unsolved QPushButton exit my application when clicked
-
Hi and welcome to devnet,
Which buttons triggers that ?
By the way, please use coding tags around your code (the </> button) so it makes it easier to read.
-
@JonB I used pycharm community edition to run the program and i get no error message just that the application exits when i click on a refresh button to load data from sqlite3 database
-
@SGaist when i write a function for a button to either insert data into sqlite3 DB or load data from sqlite3 DB.
-
@LT-K101
Did you step through in the debugger to watch which statements get executed and where it crashes? Or at least put inprint()
statements? -
@JonB I did insert the print () statement and it did work perfectly. I think its the database connection.
-
Out of curiosity, why not use Qt's SQL module ?
-
@SGaist I have not tried Qtsql but I'm familiar with sqlite3.
-
Then as asked before: which exact method makes your application crash ?
Which exception do you get ?
Did you try to use pdb to see what is going on ?
-
@SGaist now i can run and display my application but the syntax for connecting to the db within the PyQT5 GUI class is my problem now.
-
@LT-K101
PyQt5 does not come with its own Python documentation for Qt methods. They expect you to look at the standard C++ docs and adapt to Python. PySide does give some documentation, and should be same for PyQt5. So you should read through e.g. https://doc.qt.io/qtforpython-5/PySide2/QtSql/QSqlDatabase.html#detailed-description where there are Python examples of usingQSqlDatabase
, etc.