Hi All,
I'm having a bizarre problem with QStandardItemModel. I've implemented a pointer to a model in my mainwindow class. In a setup function in that class I create a model and point that model to the member pointer in the class. In another function, I sucessfully set it up. In still another, I successfully manipulate it. In a third, it always causes a seg fault. So clearly I'm doing something wrong. I would have to reimplement a ton of code to make a simple project, so I'm hoping first with the below snippets that it will be obvious what I'm doing wrong. Any ideas? It's like it's a scope problem, but it's all in one class.
Thanks,
Brian
In Mainwindow.h, as part of class:
In Mainwindow.h, as part of class:
QStandardItemModel * archive_model;
To copy to clipboard, switch view to plain text mode
In mainwindow.cpp:
setup(){
btx_api->getRuns(*archive_model);
get_request(){
foo = archive_model->item(ind.row(),0)->text();//foo has correct value "1"
}
other_request(){
foo = archive_model->item(ind.row(),0)->text();//causes seg fault.
}
In mainwindow.cpp:
setup(){
archive_model = new QStandardItemModel(this);
btx_api->getRuns(*archive_model);
get_request(){
foo = archive_model->item(ind.row(),0)->text();//foo has correct value "1"
}
other_request(){
foo = archive_model->item(ind.row(),0)->text();//causes seg fault.
}
To copy to clipboard, switch view to plain text mode
Bookmarks