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. reading data and storing from Qtreewidget
Forum Update on Monday, May 27th 2025

reading data and storing from Qtreewidget

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 4 Posters 652 Views
  • 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.
  • 123newuser1 Offline
    123newuser1 Offline
    123newuser
    wrote on last edited by
    #1

    hi Qt community i need your help with Qtreewidget topic
    here is the problem i want to read the coordinates to plot the graph by the tree i am not sure how to do theat i tried with item clicked signal but i am only able to select one coordinate point please tell how to do it

    i am attaching the part of the code i have tried please feel free to suggest a good approach to do what i am trying to do

    void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column)
    {
    QString point_x = item->text(column);
    qDebug() << point_x;

    double x = point_x.toDouble();
    qDebug() << x;
    

    }

    Thanks in advance

    eyllanescE 1 Reply Last reply
    0
    • 123newuser1 123newuser

      hi Qt community i need your help with Qtreewidget topic
      here is the problem i want to read the coordinates to plot the graph by the tree i am not sure how to do theat i tried with item clicked signal but i am only able to select one coordinate point please tell how to do it

      i am attaching the part of the code i have tried please feel free to suggest a good approach to do what i am trying to do

      void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column)
      {
      QString point_x = item->text(column);
      qDebug() << point_x;

      double x = point_x.toDouble();
      qDebug() << x;
      

      }

      Thanks in advance

      eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by
      #2

      @123newuser your question is unclear

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      123newuser1 1 Reply Last reply
      1
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #3

        You need to know what you want to draw before attempting to actually draw it.

        • do you want to draw all points from the tree widget?
        • do you want to draw all points which are children of selected item?
        • do you want to draw all points which are siblings of selected item?

        once you answer this, you can start working on the algorithm. Typically this would involve getting data from your model - QTreeWidget is only visual representation of model data after all.

        Then last step is to plot the points in some chart widget. Do you have some working solution here or are you looking for options?

        (Z(:^

        123newuser1 1 Reply Last reply
        1
        • sierdzioS sierdzio

          You need to know what you want to draw before attempting to actually draw it.

          • do you want to draw all points from the tree widget?
          • do you want to draw all points which are children of selected item?
          • do you want to draw all points which are siblings of selected item?

          once you answer this, you can start working on the algorithm. Typically this would involve getting data from your model - QTreeWidget is only visual representation of model data after all.

          Then last step is to plot the points in some chart widget. Do you have some working solution here or are you looking for options?

          123newuser1 Offline
          123newuser1 Offline
          123newuser
          wrote on last edited by
          #4

          @sierdzio my tree is looking like thisScreenshot from 2021-09-20 10-18-02.png
          i want to select the x coordinate from parameter1 child and y from parameter 2 child

          after selecting them and storing i am thinking of giving a push button which will initiate the new window /widget to plot the linegraph

          i am very new to Qt started learning it less than a month back
          please suggest a proper way to implement my problem

          1 Reply Last reply
          0
          • eyllanescE eyllanesc

            @123newuser your question is unclear

            123newuser1 Offline
            123newuser1 Offline
            123newuser
            wrote on last edited by
            #5

            @eyllanesc sorry for that
            here is the question i have a tree which has all the plotting points i want to select the plotting points by clicking on them and proceed to plot the graph

            the problem i am facing now is that i am only able to select single point

            jsulmJ 1 Reply Last reply
            0
            • 123newuser1 123newuser

              @eyllanesc sorry for that
              here is the question i have a tree which has all the plotting points i want to select the plotting points by clicking on them and proceed to plot the graph

              the problem i am facing now is that i am only able to select single point

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @123newuser https://doc.qt.io/qt-5/qabstractitemview.html#selectionMode-prop
              https://doc.qt.io/qt-5/qabstractitemview.html#SelectionMode-enum
              QAbstractItemView::ExtendedSelection

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              123newuser1 1 Reply Last reply
              3
              • sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #7

                OK, so you can select items with extended selection like @jsulm suggests. Then, when you click the button for plotting the data, you can get the QModelIndex es from selection. Then it's easy to get the data, you just call data() on your model, with proper QModelIndex and it will give you all you need.

                To plot the data, you can use QtCharts module.

                (Z(:^

                1 Reply Last reply
                2
                • jsulmJ jsulm

                  @123newuser https://doc.qt.io/qt-5/qabstractitemview.html#selectionMode-prop
                  https://doc.qt.io/qt-5/qabstractitemview.html#SelectionMode-enum
                  QAbstractItemView::ExtendedSelection

                  123newuser1 Offline
                  123newuser1 Offline
                  123newuser
                  wrote on last edited by
                  #8

                  @jsulm thank you i will try this

                  1 Reply Last reply
                  0
                  • 123newuser1 123newuser has marked this topic as solved on

                  • Login

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