segmentation fault when function from MainWindow is running
Code:
void MainWindow::change_gui_after_downloading(int value){
if(value){
ui->actionPc->setEnabled(false); //error here
}
else{
ui->actionPc->setEnabled(true); //error here
}
}
and method in another class
Code:
void download::access_to_gui(){
MainWindow* pointer
if(this->download_value)
pointer->change_gui_after_downloading(1);
else
pointer->change_gui_after_downloading(0);
}
When I create new object for MainWindow class in download class I get "QWidget: Must construct a QApplication before a QPaintDevice", when I create pointer for MainWindow I get "Segmentation fault" in change_gui_after_downloading(int) function.
When I run change_gui_after_downloading(int) directly in MainWindow its working.
Re: segmentation fault when function from MainWindow is running
You need to pass a pointer of your actual main window to the class download. Otherwise you deal with 0 pointers or with different main windows. (Basic C++ and has nothing to do with Qt!)
Alternatively (when download is created in MainWindow) you can use signal and slots.