Important: Please read the Qt Code of Conduct -

Function(QPoint, QPoint) return (int, int, int, int) ?

  • 4 directions of draw rect with mouse, change to direction of top-left to bottom-right.
    Why QPainter.drawRect(QRect) do not need to consider direction ?

    int xs, ys, xe, ye;
    if(startPnt.x()<endPnt.x() && startPnt.y()<endPnt.y()){xs=startPnt.x(); ys=startPnt.y(); xe=endPnt.x(); ye=endPnt.y();}
    if(startPnt.x()>endPnt.x() && startPnt.y()<endPnt.y()){xs=endPnt.x(); ys=startPnt.y(); xe=startPnt.x(); ye=endPnt.y();}
    if(startPnt.x()>endPnt.x() && startPnt.y()>endPnt.y()){xs=endPnt.x(); ys=endPnt.y(); xe=startPnt.x(); ye=startPnt.y();}
    if(startPnt.x()<endPnt.x() && startPnt.y()>endPnt.y()){xs=startPnt.x(); ys=endPnt.y(); xe=endPnt.x(); ye=startPnt.y();}

  • Not sure I got what your question is...

  • Hi, looking at the code, I think the 4 if statements are not for helping QPainter.drawRect() with its correct direction, but rather to simplify the drawing logic (you know you're always stepping in the +x and +y directions when building the mosaic).

Log in to reply