Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Get name of QML LineSeries when the LineSeries is hovered over - (LineSeries created dynamically)
QtWS25 Last Chance

Get name of QML LineSeries when the LineSeries is hovered over - (LineSeries created dynamically)

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 2 Posters 890 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.
  • Edwin F.E Offline
    Edwin F.E Offline
    Edwin F.
    wrote on last edited by Edwin F.
    #1

    I am trying to get a reference to a dynamically created LineSeries when hovered over. After the LinesSeries is created I attach a signal handler to the hovered event.

    The problem is:
    From the simplified example below, when I hover over the LineSeries it prints out the name of the last LineSeries that was added. When It should print the name of the series of each LineSeries added.
    For example if 3 LineSeries were created with names ["Line A", "Line B", "Line C" ], when hovering over each it should print each corresponding name, but instead it printing, "Line C", for all 3 LineSeries hovered event handlers. What am I doing
    wrong?

    //dataset is a dictionary(QVariant) of items where each item is the name of the line series
    for(var name in dataset) {
            var series = chart.createSeries(ChartView.SeriesTypeLine, name, xAxis, yAxis);
            series.name = name;
    
            series.hovered.connect(
                        function (point,state){
                            if (state){
                                console.log(">>>"+ name); // <- should print the name of each series
                            }
    
                        });
    

    I have a feeling it has something to do with binding the current value of the name variable to the onhovered event handler but I am not sure how to do this. I know in regular JS they do something like

    functionName.bind( { ... code ... }, this );

    Thanks for your help.

    --E

    1 Reply Last reply
    0
    • Edwin F.E Offline
      Edwin F.E Offline
      Edwin F.
      wrote on last edited by
      #2

      Bumping this hoping for a quick response. Anyone? Please, thanks

      oria66O 1 Reply Last reply
      0
      • Edwin F.E Edwin F.

        Bumping this hoping for a quick response. Anyone? Please, thanks

        oria66O Offline
        oria66O Offline
        oria66
        wrote on last edited by
        #3

        @Edwin-F. Since last night I have my thoughts in the solution without results.

        The truth is out there

        1 Reply Last reply
        0
        • Edwin F.E Offline
          Edwin F.E Offline
          Edwin F.
          wrote on last edited by
          #4

          ok thanks for trying it out

          1 Reply Last reply
          0
          • Edwin F.E Offline
            Edwin F.E Offline
            Edwin F.
            wrote on last edited by
            #5

            I guess this is not possible then

            1 Reply Last reply
            0
            • Edwin F.E Offline
              Edwin F.E Offline
              Edwin F.
              wrote on last edited by
              #6

              @Edwin-F. said in Get name of QML LineSeries when the LineSeries is hovered over - (LineSeries created dynamically):

              I have a feeling it has something to do with binding the current value of the name variable to the onhovered event handler but I am not sure how to do this. I know in regular JS they do something like
              functionName.bind( { ... code ... }, this );
              Thanks for your help.
              --E

              posted on SO maybe ill get an answer there

              link text

              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