Solved Application is crashing on A20-olimexXino-Micro board with debian jessy linux on it with Qt5.6
-
Application is crashing on A20-olimexXino-Micro board with debian jessy linux on it with Qt5.6 and backtracing giving the output:
Error: signal 11:
Critical: [bt]: ( 1 ) /lib/arm-linux-gnueabihf/libc.so.6 : + 0x24fd0 [0xb5ea2fd0] (main.cpp:134, void handler(int))
Critical: [bt]: ( 2 ) /usr/lib/arm-linux-gnueabihf/libQt5Core.so.5 : _ZNK11QObjectData17dynamicMetaObjectEv + 0x7 [0xb6335004] (main.cpp:134, void handler(int))
stack trace:
Segmentation faul_ZNK11QObjectData17dynamicMetaObjectEv:- QObjectData::dynamicMetaObject() Const
meanwhile, running the same project on ubuntu 14.04 with qt5.5.1 on it, not giving any problem.
void mqttClient::onTblClientClicked(const QModelIndex &index)
{
devStr = ui->tblClient->model()->data(ui->tblClient->model()->index(ui->tblClient->currentRow(),ui->tblClient->currentColumn())).toString();
strDelDevInfo = devStr;
qDebug() << devStr;if(listClientsItems.at(index.row())->objWidget == NULL) { MsgBox.setText("Reload Application"); MsgBox.exec(); qDebug() << "Reload Application"; return; } foreach(dev_clientsData* data, listClientsItems) { qDebug() << "foreach start"; if(devStr.compare(data->Name, Qt::CaseSensitive) == 0) { qDebug() << "if objwidget is null"; if(data->objWidget != NULL) { qDebug() << "if devstr name compaired"; ui->frame->layout()->removeWidget(formWidget); formWidget->setVisible(false); layout->addWidget(data->objWidget); data->objWidget->setVisible(true); formWidget = data->objWidget; break; qDebug() << "EO name compaired"; } } } qDebug() << "End TblClient Clicked";
}
above function is slot for QTableWidget cell click event.
when i comment
ui->frame->layout()->removeWidget(formWidget);
formWidget->setVisible(false);
layout->addWidget(data->objWidget);
data->objWidget->setVisible(true);
formWidget = data->objWidget;this part of the code, application works filne, but I have to load widget on table cell click event as it is our requirment.
Thanks in advance for any help :)
-
@Sagar-Ojha Do I need to provide some more section of code to understand the problem???
-
You are just doing something unbelievably intricate for an operation that would be trivial with a QStyledItemDelegate. Did you consider using it instead?
-
Hi
Its good description but nothing really spring to eye.
Only note is removeWidget will take out the widget from layout
but ownership remains the same.
So if the original parent is deleted, it will delete it also.
But you seem to override it anyway with
formWidget = data->objWidget;Also, this
devStr = ui->tblClient->model()->data(ui->tblClient->model()->index(ui->tblClient->currentRow(),ui->tblClient->currentColumn())).toString();Makes me nervous as one NULL and its a crash :)
-
Other possible sources of problems:
- MsgBox on the stack if you supply a parent in the constructor
- what is
layout
?
-
@mrjj is it possible
ui->tblClient->model()->data(ui->tblClient->model()->index(ui->tblClient->currentRow(),ui->tblClient->currentColumn())).toString();this will return NULL, I mean, if there is a cell present on tablewidget, only then I am able to clicke on it, and in this condition is it possible??
-
@Sagar-Ojha
Hi
Yes if only used when clicking it might be safe.
But its also a bit hard to read compared to something likeauto model = ui->tblClient->model(); auto client = ui->tblClient; int row = client -> currentRow(); int row = client -> currentColumn(); devStr = model->data( model->index ( row, col ) ).toString();
-
@mrjj This code is working fine,
What would be the correct way to remove privious widget and add another widget to a frame, am i missing something to do the same?? -
@Sagar-Ojha said in Application is crashing on A20-olimexXino-Micro board with debian jessy linux on it with Qt5.6:
What would be the correct way to remove privious widget and add another widget to a frame, am i missing something to do the same??
You mean a QFrame with a layout ?
Or do you mean how to have widgets in cells of a View class ?
If its anything to do with Table/tree views then as @VRonin suggest the right way is via
QStyledItemDelegateSo its depends :)
-
@mrjj Yes, I ment QFrame with a layout.
-
@Sagar-Ojha
Then there is nothing wrong with removeWidget as such. :)For QTableWidget stuff, delegates are "better".
-