Hi All
I am having a problem with setFont for a PushButton.
I have designer GUI which have GroupBoxes, inside these GroupBoxes I have pushbuttons, where the pushbuttons font set to sanserif, 10, Bold.
On clicking these pushbuttons I need to change the text on PushButton as well as from bold to normal.
Here is the Code Snippet for changing font for a pushbutton which is not working for me.
code:
void MainWindow::function1()
{
....
....
QObject::connect(pushButton1,
SIGNAL(clicked
()),
this,
SLOT(changeProperties
()));
}
void MainWindow::changeProperties()
{
.....
.....
/*QFont f declared in .h file*/
f.setPointSize(10);
f.setBold(false);
f.setWeight(5);
pushButton1->setFont(f);
pushButton1->setText("Changed Property");
}
void MainWindow::function1()
{
....
....
QObject::connect(pushButton1, SIGNAL(clicked()), this, SLOT(changeProperties()));
}
void MainWindow::changeProperties()
{
.....
.....
/*QFont f declared in .h file*/
f.setPointSize(10);
f.setBold(false);
f.setWeight(5);
pushButton1->setFont(f);
pushButton1->setText("Changed Property");
}
To copy to clipboard, switch view to plain text mode
I am expicitly trying to change the font properties to this pushButton widget, which should overwrite the its own properties for font or parent widget properties, if at all it is using.
I am not sure why it is not changing. Help me in this regard.
Thanks & Regards,
Arun
Bookmarks