1

Topic: two QIcon

Prompt how to compare, please, two  on their equality?

2

Re: two QIcon

Hello, TOPAZ23, you wrote: TOP> Prompt how to compare, please, two  on their equality? And what exactly in QIcon you want to compare? How you create them? If that, QIcon is a container. Can you want to compare QPixmap? If correctly to load icons it is possible to use QIcon:: cacheKey.

3

Re: two QIcon

Hello, SaZ, you wrote: SaZ> Hello, TOPAZ23, you wrote: TOP>> Prompt how to compare, please, two  on their equality? SaZ> and what exactly in QIcon you want to compare? How you create them? SaZ> if that, QIcon is a container. Can you want to compare QPixmap? SaZ> If correctly to load icons it is possible to use QIcon:: cacheKey. I have two icons, the identical size, but one is the one icon, the second - is the second, the same size, but various under the image. Here I should reveal a difference or similarity in the image. Or to receive a way to an icon the full

4

Re: two QIcon

Hello, TOPAZ23, you wrote: TOP> Hello, SaZ, you wrote: SaZ>> Hello, TOPAZ23, you wrote: TOP>>> Prompt how to compare, please, two  on their equality? SaZ>> and what exactly in QIcon you want to compare? How you create them? SaZ>> if that, QIcon is a container. Can you want to compare QPixmap? SaZ>> If correctly to load icons it is possible to use QIcon:: cacheKey. TOP> I have two icons, the identical size, but one is the one icon, the second - is the second, the same size, but various under the image. Here I should reveal a difference or similarity in the image. Or to receive a way to an icon the full I Do so: QIcon icon1 ("F:/Projects/VRTab/zoom.png"); QIcon icon2 ("F:/Projects/VRTab/zoom.png"); if (icon1.cacheKey () == icon2.cacheKey ()) int y = 0; Result always the unequal!

5

Re: two QIcon

Hello, TOPAZ23, you wrote: TOP> Result always the unequal! std:: vector <QIcon> iconVec; std:: vector <QByteArray> resultVec; iconVec.push_back (QIcon ("d:/temp/icontest1.png")); iconVec.push_back (QIcon ("d:/temp/icontest2.png")); QCryptographicHash hash (QCryptographicHash:: Md5); for (size_t i = 0; i! = iconVec.size (); i ++) {auto img = iconVec [i].pixmap (QSize (16, 16)).toImage ();//it is admissible, we foreknow the size auto bytesCnt = img.byteCount (); auto bytesPtr = (const char *) img.constBits (); hash.addData (bytesPtr, bytesCnt); resultVec.push_back (hash.result ()); hash.reset ();}////bla-bla, we compare //

6

Re: two QIcon

Hello, TOPAZ23, you wrote: TOP> I Do so: TOP> TOP> QIcon icon1 ("F:/Projects/VRTab/zoom.png"); TOP> QIcon icon2 ("F:/Projects/VRTab/zoom.png"); TOP> if (icon1.cacheKey () == icon2.cacheKey ()) TOP> int y = 0; TOP> TOP> Result always the unequal! Certainly unequal. You two times loaded the same picture. Load it at first in QPixmap, then already it transfer in both copies QIcon. Now attention, a question: and here icons, when at you.png files? You should compare two images. And here already there are many questions - to compare is pixel-by-pixel, approximately, if approximately, with what error, etc.

7

Re: two QIcon

Hello, TOPAZ23, you wrote: SaZ>> If correctly to load icons it is possible to use QIcon:: cacheKey. TOP> I have two icons, the identical size, but one is the one icon, the second - is the second, the same size, but various under the image. Here I should reveal a difference or similarity in the image. Or to receive a way to an icon full class QIconProvider {public: QIcon load (const QString& path); private: std:: map <QString, QPixmap> _cache;}; QIcon QIconProvider:: load (const QString& path) {const auto fullPath = QFileInfo {path}.absoluteFilePath (); const auto it = _cache.find (fullPath); if (it! = _cache.end ()) return QIcon {it.second}; const auto pixmap = QPixmap {fullPath}; _cache [fullPath] = pixmap; return QIcon {pixmap};} //After that already QIconProvider iconFactory; QIcon icon1 = iconFactory.load ("F:/Projects/VRTab/zoom.png"); QIcon icon2 = iconFactory.load ("F:/Projects/VRTab/zoom.png"); if (icon1.cacheKey () == icon2.cacheKey ())//... Somehow so, did not check the compiler. In general, the factory which should check is necessary, whether already such way is loaded. Or to wrap an icon in structure together with a way and to compare if needed. P.S. It is possible even at once std:: map <QString, QIcon>