我想向状态栏添加 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/