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. QTreeWidget + SQL

QTreeWidget + SQL

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 2 Posters 2.6k 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.
  • ro12man3R Offline
    ro12man3R Offline
    ro12man3
    wrote on last edited by ro12man3
    #1

    Hello! I need to work in qtreewidget(or qtreeview) with sql quieries. How to do that? Also, I need to make hierarchical model in this widget with main sql quieries and the requests of the second and third order.
    Like that:
    England
    --- London
    ------ East Café
    USA
    --- New York
    France

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

      Hi and welcome to devnet,

      What do you mean by second and third order ?

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

      ro12man3R 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        What do you mean by second and third order ?

        ro12man3R Offline
        ro12man3R Offline
        ro12man3
        wrote on last edited by
        #3

        @SGaist In this example this is London, New York, East Café. I mean, the other sql quieries. You click on England and then you see new list, I talk about that. Sorry, if I gave incorrect name for that :)

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

          So you'd like to re-run a query for each entry and populate the tree widget ?

          Sounds pretty expensive.

          What are the relation between your different entries ?

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

          ro12man3R 1 Reply Last reply
          0
          • SGaistS SGaist

            So you'd like to re-run a query for each entry and populate the tree widget ?

            Sounds pretty expensive.

            What are the relation between your different entries ?

            ro12man3R Offline
            ro12man3R Offline
            ro12man3
            wrote on last edited by
            #5

            @SGaist No, I don't want anything about that, because I just want to solve the problem. Every variant will be good.
            In my database there is 3 tables: country, city, streets. I want that:
            In QTreeWidget you see the list of countries, then if you will click on some country, you will see cities, and if you'll click on city you will see streets. Typical situation in this widget. But I don't know how to do that.

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

              Ok, then the most straight forward is to build your own model with its content based on the result of your queries.

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

              ro12man3R 1 Reply Last reply
              0
              • SGaistS SGaist

                Ok, then the most straight forward is to build your own model with its content based on the result of your queries.

                ro12man3R Offline
                ro12man3R Offline
                ro12man3
                wrote on last edited by
                #7

                @SGaist well, thank you, But I don't know how to do that. Can you explain that? Or write some links about how to solve that problem. Please, I have dedline in 7 days.

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

                  QStandardItemModel's documentation details show how to build a table or a tree model. Based on that you can build it using your query results. So you'll start by querying the content of your Country table, then while you loop on the result you'll make a query for the cities of that country and again in that loop get the places.

                  Note that this is the quick, simple and not optimized way to extract your data.

                  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
                  1

                  • Login

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