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

Unexpected result when drawing a dotted line

    XMLWordPrintable

Details

    Description

      The following example shows that drawing a dotted line (line3) with zero length will produce unexpected result.
      If I comment "BLOCK 1" out, the result is also wrong but different from OpenGL's.
      It seems that another QGraphicsItem is copied.

      #include <QtOpenGL>
      
      int main(int argc, char *argv[])
      {
      	QApplication app(argc, argv);
      
      	QGraphicsScene scene(0, 0, 700, 500);
      	QGraphicsView view;
      	view.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
      
      	// BLOCK 1
      	{
      		QGLWidget *widget = new QGLWidget(QGLFormat(QGL::SampleBuffers));
      		view.setViewport(widget);
      	}
      
      	view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
      	view.setScene(&scene);
      	view.resize(800, 600);
      	view.show();
      
      	QGraphicsRectItem *unitRect = new QGraphicsRectItem(0, 0, 1, 1);
      	unitRect->setScale(400);
      	scene.addItem(unitRect);
      
      	QPen dotPen(Qt::red, 0, Qt::DotLine);
      
      	// BLOCK 2
      	{
      		QGraphicsLineItem *line1 = new QGraphicsLineItem(0.1, 0.1, 0.1, 0.5, unitRect);
      		line1->setPen(dotPen);
      
      		QGraphicsLineItem *line2 = new QGraphicsLineItem(-5, -5, 10, 10, line1);
      		line2->setPos(line1->line().p1());
      		line2->setFlag(QGraphicsItem::ItemIgnoresTransformations);
      		line2->setPen(QPen(Qt::black));
      	}
      
      	// BLOCK 3
      	{
      		QGraphicsLineItem *line3 = new QGraphicsLineItem(0.9, 0.1, 0.9, 0.1, unitRect);
      		line3->setPen(dotPen);
      	}
      
      	return app.exec();
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            frederik Frederik Gladhorn
            anly Shouwei Niu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes