Providing image to icons without QLabel and ui
-
Hi All,
I'm new to Qt. I want to provide images to my icons without Qlabel and ui. Can someone tell me if it is possible through the combination of QIcon and QPixmap?
The following code snippet is given in the documentation but when I tried it in my computer after including following header file, gives error [ isChecked() is undeclared identifier]
#include <QMainWindow>
#include <QPainter>
#include<QPoint>
#include <QPixmap>
#include <QCheckBox>
#include<QIcon>void MyWidget::drawIcon(QPainter *painter, QPoint pos)
{
QPixmap pixmap = icon.pixmap(QSize(22, 22),
isEnabled() ? QIcon::Normal
: QIcon::Disabled,
isChecked() ? QIcon::On
: QIcon::Off);
painter->drawPixmap(pos, pixmap);
} -
Hi All,
I'm new to Qt. I want to provide images to my icons without Qlabel and ui. Can someone tell me if it is possible through the combination of QIcon and QPixmap?
The following code snippet is given in the documentation but when I tried it in my computer after including following header file, gives error [ isChecked() is undeclared identifier]
#include <QMainWindow>
#include <QPainter>
#include<QPoint>
#include <QPixmap>
#include <QCheckBox>
#include<QIcon>void MyWidget::drawIcon(QPainter *painter, QPoint pos)
{
QPixmap pixmap = icon.pixmap(QSize(22, 22),
isEnabled() ? QIcon::Normal
: QIcon::Disabled,
isChecked() ? QIcon::On
: QIcon::Off);
painter->drawPixmap(pos, pixmap);
}@Swati777999 said in Providing image to icons without QLabel and ui:
isEnabled() ? QIcon::Normal
: QIcon::DisabledSimply replace this part with either QIcon::Normal or QIcon::Disabled and see whether it works...
-
Hi,
@Swati777999 said in Providing image to icons without QLabel and ui:
isChecked()
What is MyWidget's base class ?
If it's just QWidget then it does not have a isChecked method as the error tells you.What exactly is your goal with MyWidget ?