Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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 ?
    https://github.com/sonichy/HTYPaint_Qt/blob/master/imagewidget.cpp#L738

    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