Results 1 to 2 of 2

Thread: Explode Pie Slice when Hover Mouse

  1. #1
    Join Date
    Jan 2017
    Qt products

    Default Explode Pie Slice when Hover Mouse

    I would like to explode each pie slice of a pie chart when hovering the mouse over each slice. I've looked in pie-slice docs and found onHover, but cannot figure out the syntax to get each slice to explode when hovered.

    I create the pie slices like this:
    Qt Code:
    1. if pie1 > 0:
    2. _slice = series.append('Equity  ' + str("{:.0f}%".format(pie1 * 100)), pie1)
    3. _slice.setBrush(QColor('#FF00FF'))
    4. _slice.setLabelFont(QFont(self.pieFont))
    To copy to clipboard, switch view to plain text mode 
    If it's possible to do this, what would I add to or change the above code?

  2. #2
    Join Date
    Jan 2008
    Alameda, CA, USA
    Thanked 794 Times in 784 Posts
    Qt products
    Windows Android

    Default Re: Explode Pie Slice when Hover Mouse

    You need to connect a slot to the QPieSlice::hovered() signal for each slice. In the slot, you call _slice.setExploded( state ) (where "state" is the value passed into the slot from the signal). You can use the same slot for all of the slices, but you would have to use the QObject::sender() method in the slot to retrieve the instance of the pie slice that sent the signal.

    BTW, QPieSlice does not have any "onHover" method.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. The following user says thank you to d_stranz for this useful post:

    dennisvz (18th January 2020)

Similar Threads

  1. Debugger - Mouse hover on the variable
    By Mathan in forum Qt Tools
    Replies: 0
    Last Post: 27th August 2016, 11:06
  2. Highlighting a set of controls on mouse hover.
    By GAURAV PANT in forum Qt Programming
    Replies: 2
    Last Post: 1st March 2014, 16:22
  3. Mouse hover issue in qt 4.7
    By qtuser123 in forum Qt Programming
    Replies: 0
    Last Post: 24th September 2012, 09:37
  4. Hover on mouse over while dragging
    By mooreaa in forum Qt Programming
    Replies: 3
    Last Post: 6th February 2010, 10:31
  5. segmentation fault on mouse hover
    By elessaar in forum Qt Programming
    Replies: 6
    Last Post: 26th August 2008, 12:51

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.