Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

Updating QListView from child dialog

$
0
0
Hi All, I am new to QT programming and this forum also. So please spare any misinterpretations. I have a main window application. when launched, the main application calls a function to search system drives, find particular files and update in the list view. works fine. i am launching a child dialog from the main window. and a task is to update the main window list view. when i am calling the main window update function to update the list view i am getting a segmentation fault. i am pasting the code below… please can i get some help on how to do it properly, or what is the error i am doing. myapp::myapp(QWidget *parent):QMainWindow(parent),ui(new Ui::myapp) { ui->setupUi(this); ui->listView->setViewMode(QListView::IconMode); // setting the model to the current dialog , value declared in header model = new QStandardItemModel(this); // function to enumerate and update volumes to list updateList(); } Void myapp::updateList() { // function gets specific files from all the local drives and calls The updateListView(passing file name as parameter) updateListView(filename); } // function to launch the dialog from main application void myapp:nbtnclicked() { mydialog mdiaog; mdialog.setModal(true); mdialog.exec(); } // function to insert the value of file into the QFileList void myapp:: updateListView (QString file) { int row = model->rowCount(); model->insertRows(row,1); QStandardItem * item = new QStandardItem(QIcon(“C:\\Users\\Test\\Desktop\\med iaa\\red.bmp”),file); model->appendRow(item); ui->listView->setIconSize(QSize(70,80)); ui->listView->setModel(model); } WORKS FINE ON APPLICATION INITIALIZATION But when called from a child dialog, i.e. I am calling the updateListView(QString fie) from the child dialog, which is launched by the above main application, segmentation error is caused. Code I am using to call the main application function from child dialog is bool myDialog::updateGui(QString path) { ((myapp*)parent())->updateListView (fileName); return true; } Function is called OK, but throws segmentation error in Main Applications, updateListView()

Viewing all articles
Browse latest Browse all 18427

Trending Articles