QWidget::paintEngine: больше не следует вызывать
QPainter::begin: Устройство рисования вернуло engine == 0, тип: 1
QPainter:
Мне нужно знать, что такое тип: 1 и почему отображается эта ошибка.
Мой код:
iconwidget.h
Код: Выделить всё
class IconWigdet : public QAbstractButton
{
Q_OBJECT
QRect *iconarea;
QPainter p;
QPixmap *icon;
public:
explicit IconWigdet(QRect *rectangle,QPixmap *tempicon);
void paintEvent(QPaintEvent *);
};
Код: Выделить всё
IconWigdet::IconWigdet(QRect *rectangle,QPixmap *tempicon)
{
iconarea = new QRect();
*iconarea = *rectangle ;
icon = new QPixmap(*tempicon);
this->setGeometry(0,0,iconarea->width(),iconarea->height()+20);
}
void IconWigdet::paintEvent(QPaintEvent *)
{
qDebug() x()+ 10,iconarea->height()+10, "name");
p.drawPixmap ( *iconarea,*icon );
p.end();
}
Код: Выделить всё
class GroupWidget: public QWidget
{
Q_OBJECT
QGridLayout *groupLayout = new QGridLayout ;
QRect *rect = new QRect( 0, 0, 100, 100);
QPixmap *pimap = new QPixmap("../widgeticon/icons/ball.png");
IconWigdet *icon = new IconWigdet(rect,pimap);
public:
GroupWidget();
};
Код: Выделить всё
GroupWidget::GroupWidget()
{
groupLayout->addWidget(icon, 0, 1, 1, 1, 0);
this->setLayout(groupLayout);
icon->show();
QPaintEvent *e;
icon->paintEvent(e);
}
Код: Выделить всё
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
GroupWidget *Gw = new GroupWidget;
Gw->show();
return a.exec();
}
Код: Выделить всё
int main(int argc, char *argv[])
{
QApplication a(argc, argv);;
QRect *rect = new QRect( 0, 0, 100, 100);
QPixmap *pimap = new QPixmap("../widgeticon/icons/ball.png");
IconWigdet *Iw = new IconWigdet(rect,pimap);
Iw->show();
return a.exec();
}
Заранее спасибо
Подробнее здесь: https://stackoverflow.com/questions/273 ... e-0-type-1