QRect constructor



  • 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.



  • 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



  • 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!



  • 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.



  • Andre You are a great Qt Specialist...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.