[SOLVED] How to apply a font family as default through a Qt Quick app
Real use case: Nokia is encouraging developers to use Nokia Pure in apps targeting Nokia devices. Makes sense and the font looks nice. Now, how is the best way to implement this in a Qt Quick project? I could not find any hints in the QML docs and I have no idea about Qt/C++.
I want to have Nokia Pure Text as default for all text strings. If a specific item requires a different font.family (e.g. Nokia Pure Header) then I would just need to add the parameter to the item itself.
fwiw my first little Qt Quick pet project can be found at https://gitorious.org/testdef/testdef/trees/master/testdef
7 replies
In the main() function add a call to QApplication::setFont() [doc.qt.nokia.com]. Your QML elements should then use the specified font as default.
Thanks but the builder complains. Maybe I’m still doing something wrong?
- #include <QtGui/QApplication>
- #include <QtDeclarative>
- int main(int argc, char *argv[])
- {
- QDeclarativeView view;
- view.showFullScreen();
- return app.exec();
- }
…main.cpp:-1: In function ‘int main(int, char**)’:
…main.cpp:8: error: no matching function for call to ‘QApplication::setFont(const char [16])’
…QtSDK/Madde/sysroots/harmattan-nokia-meego-arm-sysroot-1122-slim/usr/include/qt4/QtGui/qapplication.h:162: candidates are: static void QApplication::setFont(const QFont&, const char*)
Try this :
- QFont nokiaFont;
- nokiaFont.setFamily("Nokia Pure Text");
You must log in to post a reply. Not a member yet? Register here!






