Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

QPainter problem when trying to draw a push button on a toolbar.

$
0
0
Hello, I’m new to Qt and using it for my thesis. This toolbar is utilized by a program called Paraview and I want to add functionality to it. When I try to add this push button below, it compiles fine, but I’m getting an error saying the painter isn’t active. How do I enable it? MyToolBarActions::MyToolBarActions(QObject* p)   : QActionGroup(p) {   QIcon icon = qApp->style()->standardIcon(QStyle::SP_MessageBoxCritical);   QStyleOptionButton opt;   opt.state = QStyle::State_Active | QStyle::State_Enabled;   opt.rect = QRect(50, 25, 100, 50);   QPainter painter;   painter.drawText(55, 30, 80, 30, Qt::AlignCenter, "MyAction");   painter.beginNativePainting();   qApp->style()->drawControl(QStyle::CE_PushButton,&opt,&painter);   painter.endNativePainting();   QAction* a = this->addAction(new QAction(icon, "MyAction", this));   //QAction* a2 = this->addAction(new QAction(icon2, "MyAction2",this));       QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(onAction())); } Thanks much.

Viewing all articles
Browse latest Browse all 18427

Trending Articles