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. How to create Pie object?
Forum Updated to NodeBB v4.3 + New Features

How to create Pie object?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 317 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.
  • T Offline
    T Offline
    TomNow99
    wrote on last edited by
    #1

    Hello,

    I would like to check if the QPoint is inside a pie, which I create using QPainter:

    drawPie(int x, int y, int width, int height, int startAngle, int spanAngle)
    

    So I would like something like:

    QPie pie(int x, int y, int width, int height, int startAngle, int spanAngle);
    
    if(pie.contains(myPoint))
    {
    
    }
    

    Is a simple way to do that?

    J.HilkJ 1 Reply Last reply
    0
    • T TomNow99

      @J-Hilk You are right, but my Pie can be only half / quarter circle, so this is not basic Pythagoras.

      Look at the picture:

      circle.png

      distance between red Point and the center of the circle is very small, but that point isn't inside pie.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #4

      @TomNow99 well it still holds true, just that you have to 2 additional boundary checks.

      I don't have those at hand, from the top of my head. But this stack overflow thread has it:
      https://stackoverflow.com/a/51896645


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      4
      • T TomNow99

        Hello,

        I would like to check if the QPoint is inside a pie, which I create using QPainter:

        drawPie(int x, int y, int width, int height, int startAngle, int spanAngle)
        

        So I would like something like:

        QPie pie(int x, int y, int width, int height, int startAngle, int spanAngle);
        
        if(pie.contains(myPoint))
        {
        
        }
        

        Is a simple way to do that?

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #2

        @TomNow99 said in How to create Pie object?:

        I would like to check if the QPoint is inside a pi

        you know, that's basic Pythagoras

        (x - centerX) * (x - centerX) + (y - centerY)*(y - centerY) < radius *radius
        

        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        2
        • T Offline
          T Offline
          TomNow99
          wrote on last edited by
          #3

          @J-Hilk You are right, but my Pie can be only half / quarter circle, so this is not basic Pythagoras.

          Look at the picture:

          circle.png

          distance between red Point and the center of the circle is very small, but that point isn't inside pie.

          J.HilkJ 1 Reply Last reply
          0
          • T TomNow99

            @J-Hilk You are right, but my Pie can be only half / quarter circle, so this is not basic Pythagoras.

            Look at the picture:

            circle.png

            distance between red Point and the center of the circle is very small, but that point isn't inside pie.

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #4

            @TomNow99 well it still holds true, just that you have to 2 additional boundary checks.

            I don't have those at hand, from the top of my head. But this stack overflow thread has it:
            https://stackoverflow.com/a/51896645


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            1 Reply Last reply
            4

            • Login

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