Tips to start to work with mysql
-
Hi guys, it's the first time that i program with QT5 and mysql database also. Before to ask help i will show you the small database that i have to use and the gui of my application:
DB: http://s33.postimg.org/qqht3dc6n/Table.png
GUI: http://s33.postimg.org/cjtc013hr/gui.jpgThat's a small application that allow the user to store electronic component in the database, take care of datasheet and the location where they are stored, really simple.
Now, i made the connection with the database in my code and everything it's fine, i can also run simple query and print result with qDebug.- How can i show in the TreeView the category table (without the ID), and if the user click on the plus to expand the child will show the subcategory table (also without ID)?
I just want to say that the treeView and tableView will be read-only, to update or add something in the database i will select a row in the table and press a button to add, remove or update.
-
Hi and welcome to devnet,
If you want to show tabular data in a tree representation, then you'll to write your own model that does the table to tree conversion.
-
Nobody? I'm really stuck with this and i cannot continue.
-
There's the Editable Tree Model example that shows you how a tree model should work. This should give you a good starting point.
-
For a beginner I have found Youtube tutorials from VoidRealms very helpful. For example this tutorial is about editing in a database table:
https://www.youtube.com/watch?v=LkbfNoZrTBQ&list=PL2D1942A4688E9D63&index=56 (C++ Qt 56 - QSqlTableModel )