PDA

View Full Version : do we can't compare QIcon or QPixmap????



sudheer
12th May 2008, 14:03
hi
do we can't compare (or can't use ' == ' operator for) QIcon objects directly like this


QIcon icon1,icon2;
if (icon1 == icon2)

because when i make my project it displays on terminal as


error: no match for 'operator==' in '((studylistdialog1*)this)->studylistdialog1::buttonicon == testicon12'
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qglobal.h:1491: note: candidates are: bool operator==(QBool, bool)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qglobal.h:1492: note: bool operator==(bool, QBool)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qglobal.h:1493: note: bool operator==(QBool, QBool)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qchar.h:352: note: bool operator==(QChar, QChar)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qbytearray.h:454: note: bool operator==(const QByteArray&, const QByteArray&)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qbytearray.h:456: note: bool operator==(const QByteArray&, const char*)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qbytearray.h:458: note: bool operator==(const char*, const QByteArray&)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qstring.h:833: note: bool operator==(QString::Null, QString::Null)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qstring.h:834: note: bool operator==(QString::Null, const QString&)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qstring.h:835: note: bool operator==(const QString&, QString::Null)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qstring.h:862: note: bool operator==(const char*, const QString&)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qstring.h:875: note: bool operator==(const char*, const QLatin1String&)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qstring.h:888: note: bool operator==(const QLatin1String&, const QLatin1String&)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qstring.h:1083: note: bool operator==(const QStringRef&, const QStringRef&)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qstring.h:1086: note: bool operator==(const QString&, const QStringRef&)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qstring.h:1090: note: bool operator==(const QStringRef&, const QString&)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qstring.h:1093: note: bool operator==(const QLatin1String&, const QStringRef&)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qstring.h:1097: note: bool operator==(const QStringRef&, const QLatin1String&)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qstring.h:1118: note: bool operator==(const char*, const QStringRef&)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qstring.h:1120: note: bool operator==(const QStringRef&, const char*)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qhash.h:176: note: bool operator==(const QHashDummyValue&, const QHashDummyValue&)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qvariant.h:519: note: bool operator==(const QVariant&, const QVariantComparisonHelper&)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qpoint.h:142: note: bool operator==(const QPoint&, const QPoint&)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qpoint.h:298: note: bool operator==(const QPointF&, const QPointF&)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qsize.h:150: note: bool operator==(const QSize&, const QSize&)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qsize.h:306: note: bool operator==(const QSizeF&, const QSizeF&)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qrect.h:491: note: bool operator==(const QRect&, const QRect&)
/usr/local/Trolltech/Qt-4.3.2/include/QtCore/qrect.h:828: note: bool operator==(const QRectF&, const QRectF&)
/usr/local/Trolltech/Qt-4.3.2/include/QtGui/qevent.h:703: note: bool operator==(QKeyEvent*, QKeySequence::StandardKey)
/usr/local/Trolltech/Qt-4.3.2/include/QtGui/qevent.h:704: note: bool operator==(QKeySequence::StandardKey, QKeyEvent*)

mitro
12th May 2008, 18:02
No, you cannot compare QIcon's this way. There is no overloaded '==' operator for this class. You can get QPixmap from QIcon using QIcon::pixmap() function. Then in turn you can obtain QImage object from QPixmap with QPixmap::toImage() call. And finally you can compare QImage objects with '==' operator.

sudheer
13th May 2008, 15:53
thank q.................

i got my solution