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. Make QtCharts PieSeries clickable
Forum Updated to NodeBB v4.3 + New Features

Make QtCharts PieSeries clickable

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qtchartsclickeventqml
3 Posts 2 Posters 1.7k 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.
  • N Offline
    N Offline
    nickrobison
    wrote on 31 Mar 2016, 05:34 last edited by nickrobison
    #1

    I'm just getting started with Qt and as part of getting my feet wet I've started playing around with the QtCharts package (which I've built from source as part of 5.6 and is working fine). I'm trying to setup a clickable pieChart where the user can click on a slice and explode it. I know the PieSeries class has an onClicked signal that passes the slice being selected, but I'm not sure how to wire that up in the QML. Do I need to instantiate a MouseArea for each Slice? Or for the series as a whole? Here's some basic code that I've got working, but I'm not sure where to add the click components.

    import QtQuick 2.0
    import QtCharts 2.1
    
    Item {
        ChartView {
            x: 39
            y: 64
            width: 300
            height: 300
            PieSeries {
                name: "PieSeries"
                PieSlice {
                    value: 13.5
                    label: "Slice1"
                }
    
                PieSlice {
                    value: 10.9
                    label: "Slice2"
                }
    
                PieSlice {
                    value: 8.6
                    label: "Slice3"
                }
        }
    
    }
    
    

    Any help you can provide would be greatly appreciated.

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vladstelmahovsky
      wrote on 31 Mar 2016, 07:00 last edited by
      #2

      just add onClicked: {} into PieSlice

      N 1 Reply Last reply 2 Apr 2016, 00:38
      0
      • V vladstelmahovsky
        31 Mar 2016, 07:00

        just add onClicked: {} into PieSlice

        N Offline
        N Offline
        nickrobison
        wrote on 2 Apr 2016, 00:38 last edited by
        #3

        @vladstelmahovsky Thanks! That worked like a charm. It also gave me a good starting for digging into the interaction code and figuring out how the mouse handlers work between QML and C++.

        1 Reply Last reply
        0

        2/3

        31 Mar 2016, 07:00

        • Login

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