[Interest] Random question Friday: Why no area() for Rects and Sizes?, path.join()?
Jason H
jhihn at gmx.com
Fri Apr 12 17:09:01 CEST 2019
1. Area of concern
I find myself wanting to know the area of rectangular things a lot. For Sizes and Rects: it's abs(width()*height()), but Rects might also have a offset from the origin.
Either way, I was wondering why this was not added to Qt already? When working with images, it gives things like pixel counts and
2. Path to enlightenment
I often miss Node and Python that has a path appender. This could have been tedious in the past but in C++11, QDir::join({parts, of, a, path, and, filename}) (declared as static QDir::join(const QStringList& parts);)
I'm aware that Qt makes file path delimiters OS-agnostic, but I find myself missing the construct as a logical concept. Also consider:
source = "file://" + appPath+ "/" + filename
which becomes:
source = QDir::join({"file://", appPath, filename})
which I would argue is slightly more readable. While Url* at it, maybe one for QUrl as well? (Not sure how to handle scheme/protocol.)
https://stackoverflow.com/questions/2217258/os-path-join-in-qt
https://stackoverflow.com/questions/740423/qt-class-for-handling-file-paths
*pun accidental, but enjoyed.
More information about the Interest
mailing list