Seema Rao
25th April 2006, 14:25
Hi all,
I have a problem with respect to paint event, I have a class ToolButton derived from QToolButton, here is its paintEvent implementation. Even though I set the instance of ToolButton as, setGeometry(10,10,60,60), I get very less reading for width and height in the paint Event, am I doing anything wrong here??
void ToolButton::paintEvent(QPaintEvent *e)
{
int co_x = (int)x() - (width() / 2);
int co_y = (int)y() - (height() / 2);
QPainter painter(this);
QPixmap mypix;
mypix.load(":images/f1u7.png");
mypix=mypix.scaled (width(),height(),Qt::IgnoreAspectRatio);
cout<<co_x<<","<<co_y<<","<<width()<<","<<height()<<endl;
painter.drawPixmap(co_x,co_y,width(),height(), mypix);
}
Thanks in advance,
Seema Rao
I have a problem with respect to paint event, I have a class ToolButton derived from QToolButton, here is its paintEvent implementation. Even though I set the instance of ToolButton as, setGeometry(10,10,60,60), I get very less reading for width and height in the paint Event, am I doing anything wrong here??
void ToolButton::paintEvent(QPaintEvent *e)
{
int co_x = (int)x() - (width() / 2);
int co_y = (int)y() - (height() / 2);
QPainter painter(this);
QPixmap mypix;
mypix.load(":images/f1u7.png");
mypix=mypix.scaled (width(),height(),Qt::IgnoreAspectRatio);
cout<<co_x<<","<<co_y<<","<<width()<<","<<height()<<endl;
painter.drawPixmap(co_x,co_y,width(),height(), mypix);
}
Thanks in advance,
Seema Rao