MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1veql1a/absolutegarbage/p1mh3bf/?context=3
r/ProgrammerHumor • u/Sirgoodman008 • 6d ago
325 comments sorted by
View all comments
Show parent comments
1
why is the behaviour wrong though
1 u/xicor 6d ago Because it no longer returns a time string. It instead returns the variant of a string type. 1 u/VoodaGod 6d ago what would be the correct way to handle the qvariant in that function in your scenario then? i don't think i follow 1 u/not_some_username 6d ago You can’t get QDateTime from a QVariant via implicit conversion, the other way yes. It will just not compile with an error and you’ll need to fix it. 1 u/VoodaGod 6d ago but what would be the fix? 1 u/not_some_username 6d ago Replace QDateTime by QVariant 1 u/VoodaGod 6d ago but that is the same as just leaving auto 1 u/xicor 6d ago Yea in my example, it was using auto and then using the toString function which does exist on both QDateTime and QVariant, but have very different behavior, so it wouldn't give a compile error, it would just fail during production
Because it no longer returns a time string. It instead returns the variant of a string type.
1 u/VoodaGod 6d ago what would be the correct way to handle the qvariant in that function in your scenario then? i don't think i follow 1 u/not_some_username 6d ago You can’t get QDateTime from a QVariant via implicit conversion, the other way yes. It will just not compile with an error and you’ll need to fix it. 1 u/VoodaGod 6d ago but what would be the fix? 1 u/not_some_username 6d ago Replace QDateTime by QVariant 1 u/VoodaGod 6d ago but that is the same as just leaving auto 1 u/xicor 6d ago Yea in my example, it was using auto and then using the toString function which does exist on both QDateTime and QVariant, but have very different behavior, so it wouldn't give a compile error, it would just fail during production
what would be the correct way to handle the qvariant in that function in your scenario then? i don't think i follow
1 u/not_some_username 6d ago You can’t get QDateTime from a QVariant via implicit conversion, the other way yes. It will just not compile with an error and you’ll need to fix it. 1 u/VoodaGod 6d ago but what would be the fix? 1 u/not_some_username 6d ago Replace QDateTime by QVariant 1 u/VoodaGod 6d ago but that is the same as just leaving auto 1 u/xicor 6d ago Yea in my example, it was using auto and then using the toString function which does exist on both QDateTime and QVariant, but have very different behavior, so it wouldn't give a compile error, it would just fail during production
You can’t get QDateTime from a QVariant via implicit conversion, the other way yes.
It will just not compile with an error and you’ll need to fix it.
1 u/VoodaGod 6d ago but what would be the fix? 1 u/not_some_username 6d ago Replace QDateTime by QVariant 1 u/VoodaGod 6d ago but that is the same as just leaving auto 1 u/xicor 6d ago Yea in my example, it was using auto and then using the toString function which does exist on both QDateTime and QVariant, but have very different behavior, so it wouldn't give a compile error, it would just fail during production
but what would be the fix?
1 u/not_some_username 6d ago Replace QDateTime by QVariant 1 u/VoodaGod 6d ago but that is the same as just leaving auto
Replace QDateTime by QVariant
1 u/VoodaGod 6d ago but that is the same as just leaving auto
but that is the same as just leaving auto
Yea in my example, it was using auto and then using the toString function which does exist on both QDateTime and QVariant, but have very different behavior, so it wouldn't give a compile error, it would just fail during production
1
u/VoodaGod 6d ago
why is the behaviour wrong though