Reputation: 218
Hi I am trying to make a function in Qt that sets the font of a QTextEdit to bold:
void TextEditor::setBold(){
if (editor->fontWeight() == 75)
editor->setFont(QFont::setBold(false));
else
editor->setFont(QFont::setBold(true));
}
I am getting error: cannot call member function 'void QFont::setBold(bool)' without object
not sure how to assign an object here?
Upvotes: 1
Views: 5910
Reputation: 56479
The method setBold
is not a static
method for using it you have to make an object.
void TextEditor::setBold(){
QFont font(editor->font());
if (editor->fontWeight() == 75)
font.setBold(false);
else
font.setBold(true);
editor->setFont(font);
}
Upvotes: 3