he guys,
Please can someone take a look at my problem?
I am so stucked in this paint thing(i am new to qt).
I have a situation which is related to mouseReleaseEvent and paintEvent. On right clicking on a graphic line on the screen, i have to draw then some text on that point.
So i have here my functions:
{
// myCode;
}
{
// myCode;
Qpainter Paint(this);
paintText(Paint, e);
}
void testClass::mouseReleaseEvent(QMouseEvent *e )
{
// myCode;
}
void testClass::paintEvent(QPaintEvent *e)
{
// myCode;
Qpainter Paint(this);
paintText(Paint, e);
}
To copy to clipboard, switch view to plain text mode
In the below function i try to right click on the chosen point in the screen and then get the text with ID() and draw it on that point. It compiles well but the there is going to be no draw on the screen, i dont see the text.
{
if (me->button() == Qt::RightButton)
{
int x = me->x();
int y = me->y();
FPoint P = DevToWin(x,y);
Test *pTest = mp->Find(mi, P, mp->Sometthing->GetFilter());
text
= QString("%1").
arg(pTest
->ID
());
if (pTest)
{
painter.drawText(x, y, text);
}
}
}
void testClass::paintText (QPainter &painter, QEvent* e)
{
QMouseEvent* me;
me = (QMouseEvent*) e;
if (me->button() == Qt::RightButton)
{
int x = me->x();
int y = me->y();
QString text;
FPoint P = DevToWin(x,y);
Test *pTest = mp->Find(mi, P, mp->Sometthing->GetFilter());
text = QString("%1").arg(pTest->ID());
if (pTest)
{
painter.drawText(x, y, text);
}
}
}
To copy to clipboard, switch view to plain text mode
What am I doing wrong? Is there another way to do it?
Can someone please help me?
Thanks in advance!
Bookmarks