Details
-
Suggestion
-
Resolution: Won't Do
-
Not Evaluated
-
None
-
6.6.2
Description
Qt user has following suggestion:
"
Lots of QCoreApplication's static methods are actually not statically callable.
For instance, when you call QCoreApplication::applicationDirPath() before creating instance, you will get an warning and empty string.
This is not desirable behavior in two aspects.
First of all, if the result depends on instance, it should be non-static method. Marking it as static makes people confused. I don't know why this is not changed when bumping Qt 6 from Qt 5, I know it is not possible to change static-ness for now because of API/ABI compatibility. This should be reserved to be fixed for Qt 7.
Second of all, actually some of such static methods can be implemented truly statically. For instance, QCoreApplication::applicationFilePath() should not depend on instance. On Linux/Unix, it will just read and parse /proc file. On Windows, GetModuleFileName() with null HMODULE will give you current process's executable path. If you want to cache the result, you can just use local scoped static variable instead of the entire application instance. This kind of static methods can be fixed without breaking compatibility, so it would be nice to see such improvement in near release.
"