Using QFont -- Getting Errors
-
Hello, I have included a link below to my sources, I can't get QFont to work, I looked at some examples and google, it throws this same error:
ContactManager.cpp: In constructor ‘ContactManager::ContactManager()’:
ContactManager.cpp:9:36: error: no matching function for call to ‘QLabel::setFont(QFont*&)’
ContactManager.cpp:9:36: note: candidate is:
/usr/include/QtGui/qwidget.h:331:10: note: void QWidget::setFont(const QFont&)
/usr/include/QtGui/qwidget.h:331:10: note: no known conversion for argument 1 from ‘QFont*’ to ‘const QFont&’I have
@
QFont *colorFont; // VariablecolorFont = new QFont("Sans Serif", 10, QFont::Bold)); // Removed that source.
colorfont = new QFont(QFont("Sans Serif"), 10, QFont::Bold, true);
@I tried it both ways, same error, if anybody can help solve this, thanks !!
http://pastebin.com/khLKKUv0 You are allowed to post links, right? thanks in advance !!
-
In ContactManager.cpp line 9, you are trying to set a font by passing a pointer to the font into the function, while it expects you to pass a const reference (practically pass by value).
You're doing:
@QFont *font;
label->setFont(font);@
while you should be doing
@QFont *font;
label->setFont(*font);@ -
[quote author="Franzk" date="1306008533"]In ContactManager.cpp line 9, you are trying to set a font by passing a pointer to the font into the function, while it expects you to pass a const reference (practically pass by value).
You're doing:
@QFont *font;
label->setFont(font);@
while you should be doing
@QFont *font;
label->setFont(*font);@[/quote]Yeah, I want the font to be bold, also, couldn't find any easy explanations of QColor, any good references you can link me to?? I'm assuming QLabel does support the Palette?
-
Have a look at style sheets.
You can experiment with it in Qt Designer. For instance have a QLabel in a form. Right mouse button click. Change style sheet ... Color ... foreground color.Using style sheets you can even control the colors and looks of you entire application instead of doing this one widget at a time.