There has a the difference about QTransform between qt5 and qt6, How can I do?
-
wrote 22 days ago last edited by hidxl 5 Aug 2025, 02:39
I created a scene (QGraphicsScene) with a range of (-360,-360,720,720), then created an item on the scene that represents a layer, and then created an item whose parent is a layeritem.
Finally, through debugging, it is found that the device matrix of item is QTransform(0.0, 9.2370219841123224e-07, 0.0,
-9.2370219841123224e-07, 0.0, 0.0,
117.01799774169922, -36.503170013427734, 1.0)In this QTransform, QT5 can click on the item normally, but not under QT6.
QT5 is considered this QTransform invertible, but QT6 is NOT .
the return value of "ok" QT5 is TRURE but QT6 is FALSE
Here's the test code:auto powertransform = QTransform(0.0, 9.2370219841123224e-07, 0.0, -9.2370219841123224e-07, 0.0, 0.0, 117.01799774169922, -36.503170013427734, 1.0); bool ok(false); auto newtr= powertransform.inverted(&ok);
-
Hi and welcome to devnet,
Which version of Qt are you using ?
Can you provide a minimal compilable example just to be sure that everybody can reproduce the failure the same way as you ? -
Lifetime Qt Championwrote 21 days ago last edited by Christian Ehrlicher 5 Aug 2025, 19:03
Nothing changed in between here - a QTransform can be inverted when the determinant is not 0 Your determinant is near zero (8.53226e-13) but not completely. Maybe you used float in Qt5 so it is 0 or a special compiler flags which uses precise math or whatever.
/edit: changed from 'is 0' to 'is not 0'
-
Nothing changed in between here - a QTransform can be inverted when the determinant is not 0 Your determinant is near zero (8.53226e-13) but not completely. Maybe you used float in Qt5 so it is 0 or a special compiler flags which uses precise math or whatever.
/edit: changed from 'is 0' to 'is not 0'
wrote 21 days ago last edited by@Christian-Ehrlicher said in There has a the difference about QTransform between qt5 and qt6, How can I do?:
a QTransform can be inverted when the determinant is 0 Your determinant is near zero (8.53226e-13) but not completely. Maybe you used float in Qt5 so it is 0 or a special compiler flags which uses precise math or whatever.
Pardon me to add my two cents, but a transformation can be inverted if and only if its determinant is different from zero, otherwise it is called a singular matrix and cannot be inverted.
-
@Christian-Ehrlicher said in There has a the difference about QTransform between qt5 and qt6, How can I do?:
a QTransform can be inverted when the determinant is 0 Your determinant is near zero (8.53226e-13) but not completely. Maybe you used float in Qt5 so it is 0 or a special compiler flags which uses precise math or whatever.
Pardon me to add my two cents, but a transformation can be inverted if and only if its determinant is different from zero, otherwise it is called a singular matrix and cannot be inverted.
wrote 21 days ago last edited by@JohanSolo
I think you should provide the following information:- What version of Qt5 which behaves "well" do you use?
- What version of Qt6 which performs "badly" do you use?
- What platform are you on?
- What compiler do you use?
- What exact flags are passed to compiler in both cases?
- Can you provide a complete program in a few lines of code which illustrates your issue?
-
@Christian-Ehrlicher said in There has a the difference about QTransform between qt5 and qt6, How can I do?:
a QTransform can be inverted when the determinant is 0 Your determinant is near zero (8.53226e-13) but not completely. Maybe you used float in Qt5 so it is 0 or a special compiler flags which uses precise math or whatever.
Pardon me to add my two cents, but a transformation can be inverted if and only if its determinant is different from zero, otherwise it is called a singular matrix and cannot be inverted.
@JohanSolo said in There has a the difference about QTransform between qt5 and qt6, How can I do?:
if and only if its determinant is different from zero,
Yeah, forgot the not, thx & fixed
1/6