Discussion:
[Interest] How long is QMatrix obsolete?
Guido Seifert
2014-08-09 07:11:24 UTC
Permalink
Hi,
just out of curiosity. I updated some of my old code and noticed that QMatrix is marked obsolete.
Now, this usually is nothing to write about here. However, I wonder how it is possible to 'obsolete'
a class, on which other non obsolete Qt classes depend?

For instance QImage in:

QImage transformed(const QMatrix & matrix, Qt::TransformationMode mode = Qt::FastTransformation) const

Or QBrush:

void setMatrix(const QMatrix & matrix)

I know, this does not mean that much... obsolete does not mean that the class will be removed. And it is
a perfect example for:

" It is provided to keep old source code working. We strongly advise against using it in new code."

On the other hand...and strongly IMHO... Qt code should lead by example and not itself depend on obsolete code.

Guido
Иван Комиссаров
2014-08-09 07:30:35 UTC
Permalink
See QImage QImage::transformed(const QTransform & matrix, Qt::TransformationMode mode = Qt::FastTransformation) const

QTransform differs from QMatrix(obsolete) in that it is a true 3x3 matrix, allowing perspective transformations. QTransform's toAffine() method allows casting QTransform to QMatrix(obsolete). If a perspective transformation has been specified on the matrix, then the conversion will cause loss of data.

QTransform is the recommended transformation class in Qt.


é×ÁÎ ëÏÍÉÓÓÁÒÏ×
Post by Guido Seifert
Hi,
just out of curiosity. I updated some of my old code and noticed that QMatrix is marked obsolete.
Now, this usually is nothing to write about here. However, I wonder how it is possible to 'obsolete'
a class, on which other non obsolete Qt classes depend?
QImage transformed(const QMatrix & matrix, Qt::TransformationMode mode = Qt::FastTransformation) const
void setMatrix(const QMatrix & matrix)
I know, this does not mean that much... obsolete does not mean that the class will be removed. And it is
" It is provided to keep old source code working. We strongly advise against using it in new code."
On the other hand...and strongly IMHO... Qt code should lead by example and not itself depend on obsolete code.
Guido
_______________________________________________
Interest mailing list
http://lists.qt-project.org/mailman/listinfo/interest
Guido Seifert
2014-08-09 07:55:28 UTC
Permalink
Yes, and even QTransform has a constructor, which uses the old QMatrix.
Naturally all this QMatrix dependencies cannot be removed without breaking thousands of programs,
but it makes one wonder what sense it makes to mark QMatrix as obsolete. It can never be removed.
And if in the unlikely event that a bug is discovered in QMatrix, it has to be fixed. For the same
reason that it cannot be removed: Far too much code depends on it. I doubt that even for a Qt 6
version this kind of breakage will be accepted.

Guido

On Sat, 9 Aug 2014 11:30:35 +0400
Post by Иван Комиссаров
See QImage QImage::transformed(const QTransform & matrix, Qt::TransformationMode mode = Qt::FastTransformation) const
QTransform differs from QMatrix(obsolete) in that it is a true 3x3 matrix, allowing perspective transformations. QTransform's toAffine() method allows casting QTransform to QMatrix(obsolete). If a perspective transformation has been specified on the matrix, then the conversion will cause loss of data.
QTransform is the recommended transformation class in Qt.
Gunnar Sletta
2014-08-09 08:16:22 UTC
Permalink
All uses of QMatrix have an equivalent version which uses QTransform. If you want a proper matrix, use QMatrix3x3 or QMatrix4x4.

cheers,
Gunnar
Post by Guido Seifert
Yes, and even QTransform has a constructor, which uses the old QMatrix.
Naturally all this QMatrix dependencies cannot be removed without breaking thousands of programs,
but it makes one wonder what sense it makes to mark QMatrix as obsolete. It can never be removed.
And if in the unlikely event that a bug is discovered in QMatrix, it has to be fixed. For the same
reason that it cannot be removed: Far too much code depends on it. I doubt that even for a Qt 6
version this kind of breakage will be accepted.
Guido
On Sat, 9 Aug 2014 11:30:35 +0400
Post by Иван Комиссаров
See QImage QImage::transformed(const QTransform & matrix, Qt::TransformationMode mode = Qt::FastTransformation) const
QTransform differs from QMatrix(obsolete) in that it is a true 3x3 matrix, allowing perspective transformations. QTransform's toAffine() method allows casting QTransform to QMatrix(obsolete). If a perspective transformation has been specified on the matrix, then the conversion will cause loss of data.
QTransform is the recommended transformation class in Qt.
_______________________________________________
Interest mailing list
http
Guido Seifert
2014-08-09 08:34:48 UTC
Permalink
That's not what I meant. I just question whether it makes sense to declare a class like QMatrix obsolete.
It is not like QFtp or QHttp, QMatrix is so entwined in old code, it can never be removed or changed.
The obsolete warning is under those circumstances totally useless. It says:

"We _strongly_ advise against using it in new code."

Why? What could happen in the worst case? I think: Absolutely nothing. :-)
Maybe it could be removed in a Qt6 version. But this would make a Qt5->Qt6 transition as hard as the
Qt3->Qt4 transition. I wonder how high the chances are for this to happen.

Guido

On Sat, 9 Aug 2014 08:16:22 +0000
Post by Gunnar Sletta
All uses of QMatrix have an equivalent version which uses QTransform. If you want a proper matrix, use QMatrix3x3 or QMatrix4x4.
André Somers
2014-08-09 10:39:01 UTC
Permalink
Why would you think that? For what yse of QMatrix is QTransform not an (almost) drop-in replacement with more capabilities? I think it is perfectly reasonable to remove QMatrix in Qt 6, including all methods in other classes that take a QMatrix as an argument. The same goes for QRegExp by the way.

André

Verstuurd vanaf mijn iPhone
Post by Guido Seifert
That's not what I meant. I just question whether it makes sense to declare a class like QMatrix obsolete.
It is not like QFtp or QHttp, QMatrix is so entwined in old code, it can never be removed or changed.
"We _strongly_ advise against using it in new code."
Why? What could happen in the worst case? I think: Absolutely nothing. :-)
Maybe it could be removed in a Qt6 version. But this would make a Qt5->Qt6 transition as hard as the
Qt3->Qt4 transition. I wonder how high the chances are for this to happen.
Guido
On Sat, 9 Aug 2014 08:16:22 +0000
Post by Gunnar Sletta
All uses of QMatrix have an equivalent version which uses QTransform. If you want a proper matrix, use QMatrix3x3 or QMatrix4x4.
_______________________________________________
Interest mailing list
http://lists.qt-project.org/mailman/listinfo/interest
Guido Seifert
2014-08-09 12:16:07 UTC
Permalink
On Sat, 9 Aug 2014 12:39:01 +0200
Post by André Somers
Why would you think that?
Not worth the effort? Too much trouble for too less gain?
Post by André Somers
For what yse of QMatrix is QTransform not an (almost) drop-in replacement with more capabilities?
I absolutely agree, QTransform is by far superior. But I see the problem in your "(almost)".
Post by André Somers
I think it is perfectly reasonable to remove QMatrix in Qt 6, including all methods in other classes
that take a QMatrix as an argument.
I am not sure about this. It is a lot of stuff, which uses QMatrix directly and even more indirectly.
If there won't be a tool "qt5toqt6.sh" and I had a huge code base, which I had to port, I'd probably write
a wrapper around QTransform... with the name QMatrix. ;-)
Post by André Somers
The same goes for QRegExp by the way.
I don't think QRegExp is that widely used. And at least in my code it is always very localized. Are there
functions, which take QRegExp as a parameter? I think QRegExp plays in a totally different league than
QMatrix.

Guido
Thiago Macieira
2014-08-09 13:21:18 UTC
Permalink
Post by André Somers
Why would you think that? For what yse of QMatrix is QTransform not an
(almost) drop-in replacement with more capabilities? I think it is
perfectly reasonable to remove QMatrix in Qt 6, including all methods in
other classes that take a QMatrix as an argument. The same goes for QRegExp
by the way.
QRegExp is a little hard since there's a lot of code inside Qt *using*
QRegExp, not just taking it. Also, we've ended up needing regular expressions
in the bootstrapped programs (qmake, moc, rcc), for which bootstrapping PCRE
would be a real PITA.

However, yes, we should start to fix those codebases now in Qt 5 so that
removal in Qt 6 is as simple as removing the class and some #ifdefs.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
Tr3wory
2014-08-12 09:33:12 UTC
Permalink
Post by Guido Seifert
That's not what I meant. I just question whether it makes sense to declare a class like QMatrix obsolete.
It is not like QFtp or QHttp, QMatrix is so entwined in old code, it can never be removed or changed.
I think it depends on the code. For example I used QHttp frequently,
but I don't really remember using QMatrix.

But anyway, since it's obsolete, you should use QTransform in your new
code, and change to QTransform in your old code any time you touch it
for any reason. That way you can remove QMatrix gradually, and since
you have functions to convert between the two back and forth, this
process is fairly simple. Not like in the QHttp case...

tr3w

Loading...