Tips to start to work with mysql
-
wrote on 8 Jun 2016, 16:56 last edited by WarOfDevil 6 Aug 2016, 16:57
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.
-
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.
wrote on 8 Jun 2016, 22:18 last edited byThanks for the quick reply :)
Could you please show me an example of how to do it? I tryed to google but i'm a bit confused. -
wrote on 9 Jun 2016, 11:20 last edited by
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.
-
wrote on 12 Jun 2016, 13:09 last edited by
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 )
1/6