Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Circle which supports any type of screen size.
Qt 6.12 LTS is out! See what's new in the release blog

Circle which supports any type of screen size.

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 621 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.
  • J Offline
    J Offline
    JasmineSethi
    wrote on last edited by JasmineSethi
    #1

    How to make a circle (may be using a rectangle) such that if screen size changes still it gives the circle view?

    This is when sreen is minimized:
    0_1556016850000_bbec23c8-15d4-41d6-b8bd-257a0c2dfafb-image.png

    This is when screen is maximized:
    0_1556016905053_45d770d3-8df8-4c06-9f29-37c3cab1b5c4-image.png

    How to calculate width and height so that even in any type of screen it gives perfect shape?

    J.HilkJ 1 Reply Last reply
    0
    • J JasmineSethi

      How to make a circle (may be using a rectangle) such that if screen size changes still it gives the circle view?

      This is when sreen is minimized:
      0_1556016850000_bbec23c8-15d4-41d6-b8bd-257a0c2dfafb-image.png

      This is when screen is maximized:
      0_1556016905053_45d770d3-8df8-4c06-9f29-37c3cab1b5c4-image.png

      How to calculate width and height so that even in any type of screen it gives perfect shape?

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

      hi @JasmineSethi

      I would suggest the following:

      ....
      Rectangle{
          anchors.centerIn: parent
          height: Math.min(parent.width, parent.height)
          width:height
          radius: width/2
          color:"red"
      }
      
      ...
      

      should result in a centered red circle adjusting itself to any width and height of the parent item


      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.

      J 1 Reply Last reply
      5
      • J.HilkJ J.Hilk

        hi @JasmineSethi

        I would suggest the following:

        ....
        Rectangle{
            anchors.centerIn: parent
            height: Math.min(parent.width, parent.height)
            width:height
            radius: width/2
            color:"red"
        }
        
        ...
        

        should result in a centered red circle adjusting itself to any width and height of the parent item

        J Offline
        J Offline
        JasmineSethi
        wrote on last edited by
        #3

        @J.Hilk
        That's really awesome. Thank u very much.

        1 Reply Last reply
        1

        • Login

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