Qt5 'QFontDatabase' class
-
HI
I installed Qt5 in ubuntu 20.04 using the file:
qt-unified-linux-x64-4.0.1-1-online.run
Some libraries were missing to compile the program and I installed them with these commands:
sudo apt-get update
sudo apt-get install libqt5script5
sudo apt-get install qtscript5-dev
sudo apt-get install gcc-avr
sudo apt install libqt5serialport5-dev
sudo apt-get install -y libqt5svg5-devNow I would like to use the 'QFontDatabase' class but when I insert in the code:
#include <QFontDatabase>
The compiler tells me: 'QFontDatabase' file not found
How can I install this class?
Thank you
Greetings
-
HI
I installed Qt5 in ubuntu 20.04 using the file:
qt-unified-linux-x64-4.0.1-1-online.run
Some libraries were missing to compile the program and I installed them with these commands:
sudo apt-get update
sudo apt-get install libqt5script5
sudo apt-get install qtscript5-dev
sudo apt-get install gcc-avr
sudo apt install libqt5serialport5-dev
sudo apt-get install -y libqt5svg5-devNow I would like to use the 'QFontDatabase' class but when I insert in the code:
#include <QFontDatabase>
The compiler tells me: 'QFontDatabase' file not found
How can I install this class?
Thank you
Greetings
-
@feri said in Qt5 'QFontDatabase' class:
qt-unified-linux-x64-4.0.1-1-online.run
Why such an ancient Online Installer? At time of writing the Linux Online Installer was version 4.6.1. Through it you can access Qt 5.15.2, including a deprecated Qt Script but not QSerialPort.
Ubuntu's 20.04 repository contains Qt 5.12.8: qt5-default
You are better off sticking to one or the other. The distro version is more complete (and more recent for Ubuntu 22.04 (qtbase5-dev qt5-qmake))@feri said in Qt5 'QFontDatabase' class:
Now I would like to use the 'QFontDatabase' class but when I insert in the code:
#include <QFontDatabase>
The compiler tells me: 'QFontDatabase' file not found
How can I install this class?QFontDatabase is part of any default Qt installation.
The include will be found if the relevant settings are made in your qmake PRO file or CMakeLists.txt.@feri said in Qt5 'QFontDatabase' class:
Some libraries were missing to compile the program and I installed them with these commands:
sudo apt-get install gcc-avrNothing at all to do with Qt. If you are trying to cross-compile for an AVR microcontroller then you will not get far.
-
@feri said in Qt5 'QFontDatabase' class:
qt-unified-linux-x64-4.0.1-1-online.run
Why such an ancient Online Installer? At time of writing the Linux Online Installer was version 4.6.1. Through it you can access Qt 5.15.2, including a deprecated Qt Script but not QSerialPort.
Ubuntu's 20.04 repository contains Qt 5.12.8: qt5-default
You are better off sticking to one or the other. The distro version is more complete (and more recent for Ubuntu 22.04 (qtbase5-dev qt5-qmake))@feri said in Qt5 'QFontDatabase' class:
Now I would like to use the 'QFontDatabase' class but when I insert in the code:
#include <QFontDatabase>
The compiler tells me: 'QFontDatabase' file not found
How can I install this class?QFontDatabase is part of any default Qt installation.
The include will be found if the relevant settings are made in your qmake PRO file or CMakeLists.txt.@feri said in Qt5 'QFontDatabase' class:
Some libraries were missing to compile the program and I installed them with these commands:
sudo apt-get install gcc-avrNothing at all to do with Qt. If you are trying to cross-compile for an AVR microcontroller then you will not get far.
HI
Thank you for answering me.
By "qmake PRO file" you mean the project file "appname.pro" and if that's what I need to add an entry like this "QT += widgets".
But what exactly should I write, I'm not an expert in Qt.
Thank you
Greetings -
HI
Thank you for answering me.
By "qmake PRO file" you mean the project file "appname.pro" and if that's what I need to add an entry like this "QT += widgets".
But what exactly should I write, I'm not an expert in Qt.
Thank you
GreetingsYes. Minimal example.
QT = widgets CONFIG += c++17 SOURCES += \ main.cpp
main.cpp:
#include <QApplication> #include <QTextEdit> #include <QFontDatabase> int main(int argc, char *argv[]) { QApplication a(argc, argv); QTextEdit edit; const QStringList list = QFontDatabase::families(); edit.setText(list.join('\n')); edit.show(); return a.exec(); }
Build:
qmake make ./test
-
HI
Thank you for answering me.
By "qmake PRO file" you mean the project file "appname.pro" and if that's what I need to add an entry like this "QT += widgets".
But what exactly should I write, I'm not an expert in Qt.
Thank you
GreetingsYes, that's that file and its literally that line that you can add.
Since you are new to that, you should check the qmake manual which is pretty extensive.
-
Yes. Minimal example.
QT = widgets CONFIG += c++17 SOURCES += \ main.cpp
main.cpp:
#include <QApplication> #include <QTextEdit> #include <QFontDatabase> int main(int argc, char *argv[]) { QApplication a(argc, argv); QTextEdit edit; const QStringList list = QFontDatabase::families(); edit.setText(list.join('\n')); edit.show(); return a.exec(); }
Build:
qmake make ./test
@ChrisW67
Thanks I succeeded I got the list of installed fonts using your example with a small modification.
I use QtCreator.int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QFontDatabase dat;
QTextEdit edit;
const QStringList list = dat.families();
edit.setText(list.join('\n'));
edit.show();
return a.exec();
}
Greetings -
@ChrisW67
Thanks I succeeded I got the list of installed fonts using your example with a small modification.
I use QtCreator.int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QFontDatabase dat;
QTextEdit edit;
const QStringList list = dat.families();
edit.setText(list.join('\n'));
edit.show();
return a.exec();
}
Greetings -