开发者

Qt creator C++, adding many labels to statusbar

开发者 https://www.devze.com 2023-02-23 03:44 出处:网络
I would like to add 3 items to statusbar. Shouldn\'t each be in its own label? Is that possible? When I tried to add a second label, it gave me an error.

I would like to add 3 items to statusbar. Shouldn't each be in its own label?

Is that possible? When I tried to add a second label, it gave me an error.

File mainwindow.h,

开发者_如何学C
QLabel *m_statusLabel;
QLabel *m_pointLabel;

File mainwindow.cpp,

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

It works perfectly with one label, but when I add a second, then I get the following.

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


I found the problem. I forgot to create QLabels, so I added this:

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

精彩评论

暂无评论...
验证码 换一张
取 消