Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-31551

QPainterPath::intersects is broken

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • None
    • 5.0.2, 5.1.0 , 5.9.0 Beta 1
    • GUI: Painting
    • None
    • Windows 7
      Visual Studio 2012
      qt-everywhere-opensource-src-5.0.2 (built from source)

    Description

      QPainterPath::intersects doesn't detect an intersection with a rectangle properly for certain common combinations of lines and curves in a QPainterPath:

      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
      
          QGraphicsView view;
          QGraphicsScene *scene = new QGraphicsScene;
          view.setScene(scene);
          view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
          view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
      
          QPainterPath p;
          p.addRoundedRect(-10, 10, 40, 40, 10, 10);
          QRectF r(0, 0, 100, 100);
          scene->addRect(r);
          scene->addPath(p);
          qDebug() << p.intersects(r); // false, should be true
      
          view.show();
      
          return app.exec();
      }
      

      The bigger rectangle cuts 1/4 of a smaller rounded rectangle so they obviously do intersect, but p.intersects(r) reports they don't.

      Attachments

        For Gerrit Dashboard: QTBUG-31551
        # Subject Branch Project Status CR V

        Activity

          People

            sletta Gunnar Sletta
            grimreaper Alexei
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes