Table and Forms to edit records
I'm brand new to Qt so I'm not sure if this is exactly where I should post something like this so sorry if its not, just let me know where would be better.
I'm trying to create a data base with MS SQL and a GUI for users to edit it with. I found this chaper of a book that does something similar to what I want http://www.informit.com/articles/article.aspx?p=1405550&seqNum=3 and I think the code is download able here: http://www.informit.com/store/product.aspx?isbn=0132354160&DCSext.w_ptgrevartcl=C+++GUI+Programming+with+Qt4_1405550_ISBNTopTitle
I eventually want to make my application do more than that does like print and have an active botton for each record and a few other things but I don't know much about Qt right now and can worry about that later.
My main problem right now is that I only need 1 table not 2 linked tables which I think I've figured out for the 1st window that comes up but not with the 2nd window, the editing form. Basically I need a similar window and all to what is done in that section and the next of the chapter, that displays the records and then opens a form to edit them but only uses one table. Can anyone change this code easily to do that or know of another book/tutorial that I can read online and see the code to figure this out?
I'm not trying to get someone to do the work for me as I realize it seems at one point but I have already modified the code most of the way to create and display just one table on the 1st, "display", window, I think, but I cant really test it since I am creating my code as I read along the chapter. But QSqlRelationalTableModel is used a lot and there are some points where I dont know what to substitute for it or its functions or if I even need that section of code for what I need to do.
I am a bit confused. You want to download some code? Hmm, for reading I recommend this "author":http://www.qtrac.eu/marksummerfield.html:. In his books you will find many examples and descriptions line by line, as well as downloadable source code.
Try QSqlTableModel if you do not use relations in your tables. If you set this as the model for a QTableView you have a good starting point on viewing and edition tables based on a database.
[quote author="franku" date="1342024713"]I am a bit confused. You want to download some code? Hmm, for reading I recommend this "author":http://www.qtrac.eu/marksummerfield.html:. In his books you will find many examples and descriptions line by line, as well as downloadable source code. [/quote]
I dont have to download code I just say that because I would prefer to be able to see the whole code together as it should be written, since I am still learning Qt, instead of spread out in unordered snippets like in the chapter in the link i posted.
But I will check that link out thanks franku.
AFAIK those books (found at your link as well) provide less complex examples on how to use the model/view with SQLTables in comparison to the mentioned above or at least getting started with Qt. You may also have a look at the QT documentation, there you will find code snippets that might help your code get running. Maybe "this":http://doc.qt.nokia.com/4.7-snapshot/qsqltablemodel.html#details is a starting point for a small table example.