Change fonts in Qt application on Windows10 - qt

I installed qt5 application (Mendeley Desktop) from here by using the instraller on windows10, and I don't like the default font; MS Gothic.
Is there some ways to change fonts in a qt5 application which I didn't build from source code?
Thanks in advance!

If they bundled the font into the application binary (via QRC), I'm afraid you can't.
Otherwise, you can check in the application installation folders if by any chance the font is loaded at runtime. In that case you just need to replace it (by keeping the original name) with your preferred one.
Same thing if they use the system font, but that would compromise all the other apps using MS Gothic.

Related

TestApplication with Qt5.9 and embedded linux on Raspberry Pi 3

Setting up Qt5.9 on my RaspberryPi3 with raspbian-lite version of image.
Next compile test application qtbase/examples/opengl/qopenglwidget
With run I can see next message
QFontDatabase: Cannot find font directory /usr/local/qt5pi/lib/fonts.
Note that Qt no longer ships fonts. Deploy some (from http://dejavu-fonts.org for example) or switch to fontconfig.
Application was running, but there is no any text.
I want to use standard fonts, but I don't now how I can do it.
OR, How to use FREE-Types from http://dejavu-fonts.org.
Please help me, somebody
I found right answer. It was very simple:
You must add any font (*.ttf) in-to directory /usr/local/qt5pi/lib/fonts on raspberryPi. For example, I use free fonts from
http://dejavu-fonts.org.

SVG icon is not showing up in a Qt, portable application under Ubuntu

For some reason, I want to publish my application as a portable one. That is, avoiding the pre-installed shared libraries and use my own ones, shipped together with the app.
Long story short. Following the advises on this helpful page, I found that the window icon, which is an svg, not showing up in the foreign computer. What did I miss?
Turns out a shared library it needs cannot be found.
In Windows, you have to put Qt5Svg.dll in the same folder of the exe. And in Linux, besides the libQt5Svg.so.5, iconengines/libqsvgicon.so is also needed.

How can I compile Qt app in Linux using Windows style?

I'm developing a Qt Widgets application and due to compile performance issues, I started developing it in Linux Ubuntu instead of Windows. The problems is that, when compiled and run, the app appears with traditional Ubuntu style instead of Windows (7) style. Since the app is only for Windows, I'ld like to know how can I compile it inside Linux Ubuntu but making it appear with Windows style.
I tried using QApplication::setStyle(QStyleFactory::create("QWindowsStyle")); in main.cpp, without success. I guess the QtAssistant docs just aren't clear enough on how can I do this change. Any help will be appreciated.
Could you by any chance be using a Qt package that is compiled without the style? Can you try running QStyleFactory::keys() to verify that the style exists?
It can't be done, since the style's elements are rendered by Windows (or OS X), not by Qt. Qt's style implementation asks the OS libraries to provide bitmaps of those elements. If you wanted to, you could modify the style to use a disk cache for static items. You could then use the style on all platforms. The problem is that these OS-provided bitmaps are a part of the OS and thus non-redistributable.
The only plastform-specific style that at least used to be available everywhere was the old Windows 95 style, in times of Qt 3. I'm not sure what its current status is.
First check out put of QStyleFactory::keys()
then set the look by calling
qApp->setStyle("Windows");
This command will give you windows 98 look. If you want windows vista look you should configure qt sources with -style-windowsvista and rebuild all sources.
UPDATE
according to http://doc.qt.io/qt-5/qstylefactory.html#details qt style is not platform independent. So IT IS IMPOSSIBLE to have that native look in not windows platform. It's worth mentioning that in windows also Windows SDK itself is required in order to build sources of Qt otherwise your application will look like windows 98 in windows 7.

Qt: Safe Fonts for Cross Platform Desktop App

Just a thought: is there any resource somewhere with a list "safe-fonts" for a cross platform desktop Qt app that needs to run on windows, Mac and Linux (Ubuntu 10.* for instance).
and while we're on the subject, is there any way to "package" a font with the executable as part of the resources and have it run seamlessly in all three platforms?
I've never tried it but I think you can use addApplicationFont to load a font from a file. The file can be part of your app's resource.

Deploying QT app on OS X and linux

Whats the best way to deploy a QT app? I've read the documentation hosted at trolltech but is it better to link with a static library or the dynamic libraries and have the user install the framework? I don't really want anyone using my app to have to download a 160mb framework just to run a simple gui frontend.
On OS X it's a good way to do a dynamic build and post-process the resulting ".app" with the macdeployqt tool which comes with Qt starting with 4.5.
This will copy the Qt frameworks used by your application into the application bundle, which results in a larger package than building a static version of your application.
Here is what you can do to make sure you get the smallest file size possibly in a dynamic build:
First off, make sure you only include the stuff you need (in the project.pro file's QT += core gui network xml lines).
Open the application bundle and remove any unneeded "Qt Plugins" from the bundle. macdeployqt automatically compies all the Qt plugins in there, which can be kind of bulky.
Make sure you are building your application in release mode. Otherwise your application might be linked against the debug libraries of the Qt4 framework, and they are really big (for instance, well over 90 MB for the debug library vs. 16 MB of a release variant without debugging symbols). This might be what happened in your case.
If you have a large application binary, you can use UPX to compress your executable file by 40-50%.
Other than that, you should use compressed disk images to deploy your application.
One of my projects uses QtGui, QtNetwork, QtCore and QtXml and the resulting bundle is about 16 MB in size.
Hope that helps.
Unfortunately you will have to include the Qt libraries you need into your own bundle, as you cannot expect your users to have Qt installed on Mac (whereas on Linux packaging systems allow you to require at least a given version of Qt.
There is a nice tool to help you with that, which is called macdeployqt. You just need to invoke it on your bundle application and it will pack the required libraries, changing the linkage of your binary to refer to them. Without it, making bundles for Mac is a real pain (it still is, but considerably less though).
http://doc.trolltech.com/4.6/deployment-mac.html#the-mac-deployment-tool
Afterwards, you can make a .dmg image as you would do with any other app. There is an option in macdeployqt that builds a basic one.
On Linux, it's better to rely on the OS's copy of Qt, as it's almost certainly installed - for OS X, almost all apps use a statically compiled library.

Resources