I don't know very much about QTextLayout...

With this code copied from our very large application, when qtext contains "A":

        QTextLayout qLayout(qtext, f);
        qLayout.beginLayout();
        QTextLine qLine= qLayout.createLine();  // If there is no text left to 
be inserted into the layout, the QTextLine returned will not be valid 
(isValid() will return false).
        haveLine= qLine.isValid();
        if( haveLine ) {
                qreal width= std::numeric_limits<double>::infinity();   
//INFINITY;
                qLine.setLineWidth(width);      // everything on one line.
                qLine.setPosition(QPointF(xPos, yPos)); // top/left of first 
character
        }
        qLayout.endLayout();

        qDebug() << "qLayout.isValidCursorPosition(0) =" << 
qLayout.isValidCursorPosition(0);
        qDebug() << "qLayout.isValidCursorPosition(1) =" << 
qLayout.isValidCursorPosition(1);
        qDebug() << "qLayout.isValidCursorPosition(2) =" << 
qLayout.isValidCursorPosition(2);

When built with Qt 4.8.6, I get 
qLayout.isValidCursorPosition(0) = true 
qLayout.isValidCursorPosition(1) = false 
qLayout.isValidCursorPosition(2) = false 

whereas with Qt 5.3.0 I get
qLayout.isValidCursorPosition(0) = true
qLayout.isValidCursorPosition(1) = true
qLayout.isValidCursorPosition(2) = false

It seems like the Qt 5 output makes sense- the position after the last (only) 
character on the line should be a valid cursor position (that's where the next 
character typed will go, right?). But just in case this is a bug in Qt 5, I'd 
like to avoid changing the code to accommodate a bug...

-John Weeks

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to