Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Brainstorm
  4. QRect constructor
Qt 6.11 is out! See what's new in the release blog

QRect constructor

Scheduled Pinned Locked Moved Brainstorm
5 Posts 5 Posters 4.3k Views 1 Watching
  • 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.
  • K Offline
    K Offline
    Kolyunya
    wrote on last edited by
    #1

    I don't really know, where to post this, sorry.

    I just want to share some thoughts and to know your opinion. While working with Qt I've needed many times to construct a QRect from two random points. This means, I do not know what are they: topLeft or topRight or bottomLeft or bottomRight.

    So I think the QRect needs a constructor from two random points. What do you think?

    Example: user selects some area on a "desktop", we get two points: where he presses mouse and where he releases it. He can make a selection in any direction.

    I do know how to solve this. I'm talking about adding this feature to some or the next releases of Qt. I think it would be useful.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      messi
      wrote on last edited by
      #2

      Hi Kolyunya

      What you would need is a function which checks from where to where the user selected the area on the desktop. There are four possibilities for a rect. So I don't think that a new constructor in QRect is really necessary but thats only my opinion.

      Cheers J

      1 Reply Last reply
      0
      • JeroentjehomeJ Offline
        JeroentjehomeJ Offline
        Jeroentjehome
        wrote on last edited by
        #3

        Hmm, just catch the mouse event and the "start" position and "stop" position would give a positive of negative value. Put those three (2 points and the direction) in a signal and the QRect will be able to be made with the given constructors. The QRect shouldn't have any idea why/how or who did create the rectangle IYAM, but your application might require it anyway.
        Happy coding!

        Greetz, Jeroen

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          So, why don't you do this then?
          @
          QRect myRect = QRect(point1, point2).normalized();
          @

          I don't think a special constructor is needed for this.

          1 Reply Last reply
          0
          • V Offline
            V Offline
            vittalonline
            wrote on last edited by
            #5

            Andre You are a great Qt Specialist...

            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