#include <QtGui>
#include "test.h"
{
setupUi(this);
m_drawer->installEventFilter(this);
[COLOR="red"]connect(pushButton, SIGNAL( clicked()), this, SLOT( doSomething() ));[/COLOR]
}
void Test::doSomething()
{
i want to call a method that paint something of new on the widget!!
}
{
if (o
== m_drawer
&& e
->type
() == QEvent::Paint) { painter.setPen(Qt::blue);
painter.
setFont(QFont("Arial",
30));
painter.drawText(m_drawer->rect(), Qt::AlignCenter, "Qt");
return true;
}
}
painter.
setRenderHint(QPainter::Antialiasing,
true);
painter.
setPen(QPen(Qt
::black,
15, Qt
::SolidLine, Qt
::RoundCap,Qt
::MiterJoin));
painter.
setBrush(QBrush(Qt
::blue, Qt
::DiagCrossPattern));
painter.
setPen(QPen(Qt
::yellow,
5, Qt
::SolidLine, Qt
::RoundCap,Qt
::MiterJoin));
painter.translate(100.0,100.0);
painter.drawPie(0, 0, 300, 300, 60 * 16, 270 * 16);
painter.drawEllipse(30,30,60,60);
}
#include <QtGui>
#include "test.h"
Test::Test(QWidget *parent)
: QWidget(parent)
{
setupUi(this);
m_drawer->installEventFilter(this);
[COLOR="red"]connect(pushButton, SIGNAL( clicked()), this, SLOT( doSomething() ));[/COLOR]
}
void Test::doSomething()
{
i want to call a method that paint something of new on the widget!!
}
bool Test::eventFilter(QObject *o, QEvent *e)
{
if (o == m_drawer && e->type() == QEvent::Paint) {
QPainter painter(m_drawer);
painter.setPen(Qt::blue);
painter.setFont(QFont("Arial", 30));
painter.drawText(m_drawer->rect(), Qt::AlignCenter, "Qt");
return true;
}
return QWidget::eventFilter(o, e);
}
void Test::paintEvent(QPaintEvent *event){
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, 15, Qt::SolidLine, Qt::RoundCap,Qt::MiterJoin));
painter.setBrush(QBrush(Qt::blue, Qt::DiagCrossPattern));
painter.setPen(QPen(Qt::yellow, 5, Qt::SolidLine, Qt::RoundCap,Qt::MiterJoin));
painter.translate(100.0,100.0);
painter.drawPie(0, 0, 300, 300, 60 * 16, 270 * 16);
painter.drawEllipse(30,30,60,60);
}
To copy to clipboard, switch view to plain text mode
Bookmarks