c++ - Qt Creator C++,为状态栏添加许多标签

标签 c++ qt qt-creator

我想向状态栏添加 3 个项目。每个不应该有自己的标签吗?

这可能吗?当我尝试添加第二个标签时,出现错误。

文件mainwindow.h

QLabel *m_statusLabel;
QLabel *m_pointLabel;

文件mainwindow.cpp

statusBar()->addWidget(m_statusLabel);
statusBar()->addWidget(m_pointLabel);

它与一个标签完美配合,但当我添加第二个标签时,我会得到以下结果。

Starting C:\Users\Jansu\Desktop\cpp-praktikum05-alus\Joonistamine-build-      desktop\src\bin\Joonistamine.exe...
ASSERT: "d" in file ..\..\include/QtCore/../../src/corelib/tools/qscopedpointer.h, line   112
Invalid parameter passed to C runtime function.
Invalid parameter passed to C runtime function.
C:\Users\Jansu\Desktop\cpp-praktikum05-alus\Joonistamine-build-    desktop\src\bin\Joonistamine.exe exited with code -1073741819

最佳答案

我发现了问题。我忘记创建 QLabels,所以我添加了以下内容:

m_statusLabel = new QLabel(this);
m_pointLabel = new QLabel(this);

关于c++ - Qt Creator C++,为状态栏添加许多标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5612584/

相关文章:

c++ - -Wconversion warning while using operator <<= on unsigned char

c++ - 我的Qt程序可以编译,但是在声明中使用ifstream时崩溃

c++ - 如何从 Objective C 调用我的 Qt/C++ Dylib?

c++ - Qt程序部署到多平台,如何?

c++ - 如何在Qt中传递值?

qt-creator - 我可以在 Qt Creator 中隐藏整个 GUI 吗?

c++ - 使用 OpenGL 和 QT 进行纹理映射 - C++

c++ - 使用特征库再现张量矩阵

python - Qt 是如何工作的(确切地说)?

javascript - 使用 PySide QtCore.Slot 装饰器的多个参数