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. QML, create LineSeries at runtime
Forum Updated to NodeBB v4.3 + New Features

QML, create LineSeries at runtime

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 892 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.
  • Q Offline
    Q Offline
    qtdb
    wrote on last edited by qtdb
    #1

    My goal is to have a QML ChartView with a variable number of LineSeries added to it during runtime. It is unknown how many LineSeries will need to be added until a user selects and loads a file with the data in it.

    I tried to create all of the LineSeries inside a Repeater, with no luck. I suspect it's because ChartView doesn't know what to do with a bunch of Item's. It's not possible to have the Repeater create LineSeries directly since a Repeater doesn't work on QObject's:

    ChartView {
    
        ......
       
        Repeater {
            model: numberOfColumnsInModel / 2
        
            delegate: Item {
                LineSeries {
                    id: lineSeries
                    axisX: xAxis
                    axisY: yAxis
        
                    VXYModelMapper {
                        id: modelMapper
                        model: lineChart.model //Reimplemented QAbstractTableModel
                        xColumn: index * 2
                        yColumn: index * 2 + 1
                    }
    
                    onHovered: {
                        console.log("Do something...");
                    }
                }
            }
        }
    }
    

    In the examples I see online, each LineSeries is hard-coded--once for each line in the ChartView--and not useful to me.

    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