Unable to display text property on screen
-

Hi. I have a problem.
I think there is something wrong. It is not printing properly on the screen.
I made it print from QML.
Sometimes it works properly and sometimes it works like the picture above
What should i do. -
The problem has been successfully resolved.
But I don't know why this problem is resolved.
Problem was "font.bold "
I wrote "true" on almost every "font.bold".
So, I only left a few, and I fixed most of them to "false."
it operated well.
-

Hi. I have a problem.
I think there is something wrong. It is not printing properly on the screen.
I made it print from QML.
Sometimes it works properly and sometimes it works like the picture above
What should i do.@Jaekook-Choi said in Unable to display text property on screen:
What should i do
Provide more information.
On which platform?
On what hardware?
Which Qt version?
What font?
What are you using to print text? -
@Jaekook-Choi said in Unable to display text property on screen:
What should i do
Provide more information.
On which platform?
On what hardware?
Which Qt version?
What font?
What are you using to print text?I'm sorry
vxworks7
intel 8th
based on Qt 6.2.3
NanumGothic.ttf
through invokeMethodin CPP
QMetaObject::invokeMethod(m_pOperPPIQmlInstance, "show_c2a_key", Q_ARG(QVariant, indi));in QML
function show_c2a_key(indi)
{
if(indi === 1) {
c2a_key.text = "ABCDEFGHI"
}
}and
Text{
id: c2a_key
x: 544
y: 430
color: "green"
text: ""
font.pixelSize: 16
font.bold: true
font.preferShaping: false
}When the program runs, the terminal outputs the following statement:
QFontDatabase: Cannot find font directory /usr/local/Qt-5.15.3/lib/fonts.
Note that Qt no longer ships fonts. Deploy some (from https://dejavu-fonts.github.io/ for example) or switch to fontconfig.Is there any connection?
-
can't you ship the font with your application?
// main.cpp // register shipped font to application QFontDatabase::addApplicationFont(":/your/qrc/path/NanumGothic.ttf");You can also add the font from QML:
// qmldir singleton Fonts 1.0 Fonts.qml// Fonts.qml pragma Singleton import QtQuick 2.12 Item { property FontLoader nanumGothic: FontLoader { source: "qrc:/your/qrc/path/NanumGothic.ttf" } readonly property string indiFont: nanumGothic.name }// in any other QML Text{ text: "ABCDEF" font.family: Fonts.indiFont } -
can't you ship the font with your application?
// main.cpp // register shipped font to application QFontDatabase::addApplicationFont(":/your/qrc/path/NanumGothic.ttf");You can also add the font from QML:
// qmldir singleton Fonts 1.0 Fonts.qml// Fonts.qml pragma Singleton import QtQuick 2.12 Item { property FontLoader nanumGothic: FontLoader { source: "qrc:/your/qrc/path/NanumGothic.ttf" } readonly property string indiFont: nanumGothic.name }// in any other QML Text{ text: "ABCDEF" font.family: Fonts.indiFont }Sorry for late reply
first.
int main(int argc, char *argv[])
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QGuiApplication app(argc, argv);QSurfaceFormat format; format.setSamples(8); QSurfaceFormat::setDefaultFormat(format); int fontID = QFontDatabase::addApplicationFont(":/font/NanumGothic.ttf"); qDebug() << "Font ID : " << fontID << QFontDatabase::applicationFontFamilies(fontID); QFont defaultFont; defaultFont.setFamily("NanumGothic"); defaultFont.setPixelSize(20); defaultFont.setStyleStrategy(static_cast<QFont::StyleStrategy>(defaultFont.styleStrategy() | QFont::PreferNoShaping)); app.setFont(defaultFont); CEventFilter cEF; app.installEventFilter(&cEF); CAppContainer appContainer; appContainer.initialize(); appContainer.show(); return app.exec();}
This is my main function.
you told me to write "QFontDatabase::addApplicationFont(":/your/qrc/path/NanumGothic.ttf");"
But I've already written it.
By any chance, is there a strange part of my main function?
If I made the character print from c++, it would be printed without any problem, but if I made the character print from QML, the above problem occurred.
So I think the font is applied to c++, but the font is not applied to QML.
But If i erase code related to the font in c++, QML totally doesn't print character.
So the font is not applied?
And
Now I'm trying to second way that you said(Appliying fonts in QML)
Do i have to make a qmldir file and put one sentence that "singleton Fonts 1.0 Fonts.qml"?
Thank for read my reply :)
-
The problem has been successfully resolved.
But I don't know why this problem is resolved.
Problem was "font.bold "
I wrote "true" on almost every "font.bold".
So, I only left a few, and I fixed most of them to "false."
it operated well.