Qt创建者C ++,向状态栏添加了许多标签

时间:2011-04-10 14:58:19

标签: 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

1 个答案:

答案 0 :(得分:4)

我发现了问题。我忘了创建QLabel,所以我添加了这个:

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