From b225223d23928c1e476e1fb978e8acdd886c01ad Mon Sep 17 00:00:00 2001 From: mhf <1603291350@qq.com> Date: Sat, 29 Jul 2023 12:03:47 +0800 Subject: [PATCH] fix:Modify the bug of qtextedit; 1.Modifying qtextedit cannot display Chinese problems; 2When modifying the qtextedit display, it will not automatically scroll to the bottom problem. --- include/spdlog/sinks/qt_sinks.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/spdlog/sinks/qt_sinks.h b/include/spdlog/sinks/qt_sinks.h index 565a292c..38dc88a6 100644 --- a/include/spdlog/sinks/qt_sinks.h +++ b/include/spdlog/sinks/qt_sinks.h @@ -162,7 +162,7 @@ protected: const string_view_t str = string_view_t(formatted.data(), formatted.size()); // apply the color to the color range in the formatted message. - auto payload = QString::fromLatin1(str.data(), static_cast(str.size())); + auto payload = QString::fromUtf8(str.data(), static_cast(str.size())); invoke_params params{max_lines_, // max lines qt_text_edit_, // text edit to append to @@ -215,6 +215,7 @@ protected: // insert the text after the color range with default format cursor.setCharFormat(params.default_color); cursor.insertText(params.payload.mid(params.color_range_end)); + params.q_text_edit->setTextCursor(cursor); } QTextEdit *qt_text_edit_;