Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Tips to start to work with mysql

Tips to start to work with mysql

Scheduled Pinned Locked Moved Unsolved General and Desktop
databasetreeviewmysql
6 Posts 3 Posters 2.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • WarOfDevilW Offline
    WarOfDevilW Offline
    WarOfDevil
    wrote on last edited by WarOfDevil
    #1

    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.jpg

    That'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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      WarOfDevilW 1 Reply Last reply
      0
      • SGaistS SGaist

        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.

        WarOfDevilW Offline
        WarOfDevilW Offline
        WarOfDevil
        wrote on last edited by
        #3

        @SGaist

        Thanks 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.

        1 Reply Last reply
        0
        • WarOfDevilW Offline
          WarOfDevilW Offline
          WarOfDevil
          wrote on last edited by
          #4

          Nobody? I'm really stuck with this and i cannot continue.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            There's the Editable Tree Model example that shows you how a tree model should work. This should give you a good starting point.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • ael16A Offline
              ael16A Offline
              ael16
              wrote on last edited by
              #6

              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 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved