PDA

View Full Version : unable to drawButton using Q3Button



user_mail07
18th April 2007, 00:44
unable to drawButton using Q3Button

CMenuButtons::EnableButtons( int pIndex )
{
1. // QButton *menuButton;

=============//Replaced Line no 1. QButton with QAbstractButton in Qt 4==================

1. // QAbstractButton *menuButton;


2. int i;

3. for (i = 0; i < menuButton; i++)
{
4. menuButton = tButtonGroup->find( button[ index ] );

5. if ( menuButton != NULL )
{
if ( pIndex )
{
menuButton->show();
}
else
{
menuButton->hide();
}
}
}
}


As mentioned in documentation , QAbstractButton has no equivalent for the Q3Button::drawButton(QPainter *) virtual function. I am just confused Where i need to call drawButton( ) function to draw button. After porting code to Qt 4 , I am not able to draw button at all.

but if I replace with QButton with Q3Button I am getting error at Line 4

saying error C2440: '=' : cannot convert from 'QAbstractButton *' to 'Q3Button .

vermarajeev
18th April 2007, 04:33
Please use
... tags. It makes code more understable. And if possible provide more information about what you are looking for.

aamer4yu
18th April 2007, 04:55
I am not aware much of Qt 3 ... but i guess u needed to override some drawButton function/.... u are trying the same using Q3Button...

but in Qt 4 I guess the buttons are drawn automatically and u dont need too override any of the functions.... also check the QPushButton, QToolButton... u might be looking for them... if u want them to be checable, use the function setChecable(true)...

hope this helps :)

vermarajeev
18th April 2007, 05:40
From QtAssistance-->


The solution is to reimplement QWidget::paintEvent() in your QAbstractButton subclass as follows:
void MyButton::paintEvent(QPaintEvent *)
{
QPainter painter(this);
drawButton(&painter);
}

Hope it heps :)