Looks like you still have to figure out the basic object creation and scope work (it's C++ stuff)
//program.cpp
wnd1 w1; //this will create object on stack and will be destroyed as soon as function returns
w1.Initialize(); //this is ok
//program.cpp
wnd1 w1; //this will create object on stack and will be destroyed as soon as function returns
w1.Initialize(); //this is ok
To copy to clipboard, switch view to plain text mode
//window1.cpp
program oProg; //this not good, you are creating a global QMainWindow, that means you are trying to create a widget even before QApplication is created
void wnd1::Initialize() {
QPushButton *b
= oProg.
centralWidget()->findChild<QPushButton
*>
("button1");
// you are not supposed to get the member widgets of other class this way, it will work but will end up in problems later wnd1 w1; //this will create object on stack and will be destroyed as soon as function returns
w1.connect(b, SIGNAL(clicked()), SLOT(test())); //there is no such version of connect function, hence the error, and moreover it does not make sense to connect a object which will be deleted before this function returns. So even if you were able to get the correct version of the function, your slot will never get called, as the object itself is destroyed before this function returns
}
//window1.cpp
program oProg; //this not good, you are creating a global QMainWindow, that means you are trying to create a widget even before QApplication is created
void wnd1::Initialize() {
QPushButton *b = oProg.centralWidget()->findChild<QPushButton *>("button1"); // you are not supposed to get the member widgets of other class this way, it will work but will end up in problems later
wnd1 w1; //this will create object on stack and will be destroyed as soon as function returns
w1.connect(b, SIGNAL(clicked()), SLOT(test())); //there is no such version of connect function, hence the error, and moreover it does not make sense to connect a object which will be deleted before this function returns. So even if you were able to get the correct version of the function, your slot will never get called, as the object itself is destroyed before this function returns
}
To copy to clipboard, switch view to plain text mode
Please try, as I suggested in my earlier post
Bookmarks