I am working on a camera project. In this i have created a Window type QT Widget application. I have also added 2 separate dialog window classes which are supposed to access the functions in the MainWindow
class. One of the dialog class is able to access the functions from the main class using connect function and putting parentWidget()
calue for QObject *context
parameter. The dialog class is called on camera button using non modal method :
void MainWindow::on_addCamera_Button_clicked()
{
flag1 = 1;
if(imageFilename != ""){
c++;
camera = new CameraDialog(this);
camera->show();
img2.copyTo(im);
img2.copyTo(img);
img2.copyTo(img1);
imshow("Map",img1);
setMouseCallback("Map", onMouseClick, &p);
connect(timer_ossm, SIGNAL(timeout()), this, SLOT(gui_update_Original_Video()));
connect(timer_ossm, SIGNAL(timeout()), this, SLOT(gui_update_Image_Coordinate()));
}
else {
QMessageBox::warning(this,"..",(QString)"Enter Image!");
}
}
And the connect statements that work fine in CameraDialog
class are :
CameraDialog::CameraDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::CameraDialog)
{
ui->setupUi(this);
ui->pushButton_Done->setCheckable(true);
cout<<parentWidget()<<endl;
connect(ui->pushButton_Done,SIGNAL(clicked()),parentWidget(),SLOT(clearVal()));
connect(ui->pushButton_Done,SIGNAL(clicked()),parentWidget(),SLOT(updateFlag()));
connect(ui->pushButton_Done, SIGNAL(released()),this,SLOT(close()));
connect(ui->pushButton_Apply,SIGNAL(clicked()),parentWidget(),SLOT(updateImage());
connect(ui->pushButton_Cancel,SIGNAL(clicked()),parentWidget(),SLOT(clearVal()));
}
But when I try the same thing for another class for a different dialog window (which accessed using the same non modal approach)it show that there is no value for parentWidget()
, i.e, it shows value 0 when trying to print value of parentWidget()
. Because of this the same connect functions in the 1st dialog class(CameraDialog
) are not working. How do I solve this issue so that the second class can also access the functions in the MainWindow
class?
Thanks!