I have a problem with adding an element to a QListWidget. I have build some frame with QtDesigner and then, I want to add some elements to a list in code. Even when I write:
QListWidgetItem* i = new QListWidgetItem("text");
Q_ASSERT(stepsList);
qDebug() << "before";
stepsList->addItem(i);
qDebug() << "after";
It prints only "before" and crashes with SIGSEGV. Additionaly, I managed to get such error message with this:
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6f2a4a4 in QListWidget::count() const ()
from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
What is the reason?
Well, acceptation is needed so I'll write what was wrong:
I needed to call setupUi()
first, in order to initialize the stepsList
as @Timo Geusch wrote.
Solved.