Questions tagged [qfont]
32 questions
5
votes
1 answer
QFontMetrics give strange results for monospace font
Сan someone explain to me results of this test program?
#include
#include
#include
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QFont font;
font.fromString("Monospace,14");
…

poljak181
- 585
- 4
- 12
5
votes
1 answer
How to change QMenu font size
The code below creates a Menu with 5 Submenus and 10 Actions per each Submenu. Even while the setPointSize command is applied to the Submenus their font seem to be unaffected and it remains to be large. But the Actions font is set to a smaller size…

alphanumeric
- 17,967
- 64
- 244
- 392
4
votes
1 answer
How to select another type of font with QFont?
I am trying to assign different types of text fonts to my application with PyQt5, but I don't know how to assign a different one to the standard one, for example in my application I could only assign it 'Roboto', but if I want to change to…

Leo Odriozola
- 43
- 1
- 3
4
votes
2 answers
Is the format of QFont.toString() documented and/or stable across Qt versions?
The documentation for QFont.toString says that it returns "a comma-separated list of the attributes", but it doesn't specify what "the" attributes are or what order they come in. (Edit: the documentation has been updated so it now explicitly lists…

BrenBarn
- 242,874
- 37
- 412
- 384
4
votes
1 answer
Qt QFont selection of a monospace font doesn't work
i'm trying to make a qt widget that shows a table of qlabels displaying hex numbers.
i pass the numbers to the labels as qstrings ready to be printed and the labels work properly but the font type is the system default (a sans serif) that has…

mellotanica
- 174
- 5
- 12
3
votes
0 answers
Qt C++ Is there a way to get a list of all available system languages, including substitutes?
So, there is a QFontDatabase::families() method which returns a QStringList of all available font families probably by looking it up at local registry, such as HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts. Currently I'm…

p.ivanov
- 31
- 2
3
votes
0 answers
How to add .ttf fonts in PyQt6 using relative path?
I am building an app and need to add a custom font of my desire in it, I have tried multiple ways to get that font loaded with a relative path but have failed with the error:
qt.qpa.fonts: Populating font family aliases took 192 ms. Replace uses of…

Ray
- 31
- 3
2
votes
1 answer
Qt: the same font looks different being rendered in QML and c++
QML and c++ code use the same font.
QML:
TextEdit {
...
font: settings.font // font.preferShaping = false doesn't help
...
renderType: Text.QtRendering // Text.NativeRendering also doesn't paint…

Vladimir Bershov
- 2,701
- 2
- 21
- 51
2
votes
1 answer
"Bold" style is not available for "Sans Serif" font on QT5
We just moved our application from QT4 to QT5. We found the "Bold" style is not avialble for "Sans Serif" font on QT5. I can tell from the QFontDialog which looks below:
I also use the following code to dump all available styles under "Sans…

Jie Liu
- 107
- 1
- 7
2
votes
2 answers
Why does QFontDialog.getFont() always return the same font?
Every time I use QFontDialog.getFont() to get a font, it returns the same QFont object.
font, ok = QFontDialog.getFont()
print(font)
if ok:
self.lbl.setFont(font)
print(self.lbl.font())
Above is the code segment, and the result is below (I make…

Yao
- 53
- 7
2
votes
1 answer
Fonts Menu PyQt5 Text Editor
The Problem:
I am trying to find a way of adding a font style to text that as written by the user of my PyQt5 text editor program. I don't want to code each font into some kind of menu manually and I am wondering if there is a built-in way for the…

Richard Smith
- 77
- 7
1
vote
1 answer
How can I fill a QComboBox with all fonts from QFontDatabase?
I want to add all fonts from my pc to QComboBox, how can I do it?
I expect a combobox list which will include all fonts from my PC. As I think, it can be possible with QFontDatabase.

why
- 31
- 5
1
vote
1 answer
Why is there a mismatch in width provided by QFontMetrics and width shown by Qml Rectangle/ Text
I have written a qml and cpp file to validate and visualize QFontMetrics concept.
#include
#include
#include
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine…
user12531295
1
vote
1 answer
Set the color for QFont
I have a 'QGraphicsScene' scene and am trying to use
addText(const QString &text, const QFont &font = QFont())
to add some texts to the scene. It worked. But, I tried to change the text color but could NOT find a way to set the color for 'QFont'.…

Steven Cao
- 83
- 2
- 7
1
vote
1 answer
How do I create different font sizes for widgets but allow them to scale with font dialog in PySide2?
Let's say that I have 3 labels and each one is supposed to have different sized text. Inspect this example code:
import sys
from PySide2 import QtCore, QtGui, QtWidgets
def Fonty():
ok, font = QtWidgets.QFontDialog.getFont(tableWidget)
if…

chmedly
- 391
- 1
- 6
- 16