How can the font size of the text in a Button control be set in QML? The designer has not option, and 'font' is not a valid property of Button.
Button {
id: cmdQuit
text: qsTr("Quit")
width: 64
height: 32
}
Either use the setFont on your widget to set the font size, or set it via a style sheet: QFont font = ui->pushButton->font(); font. setPointSize(16); ui->pushButton->setFont(font);
SOLVED How to set the font size of my QPushButton? bu->setStyleSheet("font-size: 20px;"); Or if you are not a fan of qt stylesheet you can extract font of your button, and then change it : QFont font = bu->font(); font.
This is an old question, but since it comes first in search engines I'm providing an update on the situation.
For QtQuick2, unlike what Chris said, you don't need to use the contentItem property anymore. You can access the font
property directly from Button
.
Example:
Button {
id: btn
text: "Test"
font.pixelSize: 18
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With