Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can i compare 2 icons?
Forum Updated to NodeBB v4.3 + New Features

How can i compare 2 icons?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 8.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ruzik
    wrote on last edited by
    #1

    Hellow!
    How can i compare 2 icons?
    QIcon and QPixmap have not any compare method

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      Convert QPixmap to "QImage":QImage using method "toImage":http://qt-project.org/doc/qt-4.8/qpixmap.html#toImage and after that use "operator ==":http://qt-project.org/doc/qt-4.8/qimage.html#operator-eq-eq to compare.

      http://anavi.org/

      1 Reply Last reply
      1
      • R Offline
        R Offline
        Ruzik
        wrote on last edited by
        #3

        Thank you for help!

        1 Reply Last reply
        0
        • B Offline
          B Offline
          broadpeak
          wrote on last edited by
          #4

          First you have to make from QIcon to QPixmap (QIcon::pixmap(...)).
          After this you have to convert from QPixmap to QImage (QPixmap::toImage()).

          The real comparison at the end:

          @
          bool ImageComp::pixelCompareImages( const QImage &a, const QImage &b )
          {
          if( a.size() != b.size() )
          return false;
          if( a.format() != b.format() )
          return false;
          for( int x=0; x<a.width(); ++x )
          for( int y=0; y<a.height(); ++y )
          if( a.pixel(x,y) != b.pixel(x,y) )
          return false;
          return true;
          }
          @

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved