0
Hi, I’m trying to pass a mat parameter from one window to another, being activated by the click of a button. The program compiles and runs normally, but when clicking the button that activates the event, the program gives a chrash on the execution. Below the code snippet that calls to another window:
void MainWindow::on_commandLinkButton_clicked(){
Form *form = new Form();
form->setInput(this->ModFirstP);
form->execTransform();
form->setLabels();
form->show();
}
The problematic parameter is Modfirstp of type Mat, I want to set it in an attribute of the other window I am generating:
.H
void setInput(Mat&);
.cpp
void Form::setInput(Mat& in){
this->input = in;
}
Would anyone know how to pass parameters between Windows (Forms) in Qt? Or does Qt only accept Qobject objects as parameters between windows? Thanks in advance.
Yuri, I don’t have Qt installed but if I’m not too crazy the framework does not contain any Form classes (until you clone them with a Q). Is this Form class implemented by extending some Qt class? I believe that the standard Qt classes (Qwidget, Qdialog, Qmainwindow) do not contain a setInput method until I found nothing about it in the online documentation.
– Bruno Bermann
This form was another window I created using the Qt Creator IDE itself, it extends from Qwidgets, the setInput method I created to set the Mat Modfirstp attribute. Thank you for the reply.
– Yuri Pires
Yuri, now yes your question has become clearer to me. The way you are doing is correct. It remains to be seen whether the pointer passed to the other window points to a valid memory location (this may be what causes the crash). If you can also post the code that accesses this pointer in "Form" maybe I can help you more specifically.
– Bruno Bermann
After several hours of cracking my head I figured out what the problem was, you’re right @Brunobermann the statement is really right, I thought the crash problem was in the statement between the Forms, but after a while I realized I had accidentally deleted a line from my window class. I will reformulate the resolution in a reply to the post. Thank you.
– Yuri Pires
Glad you could make it, glad to help.
– Bruno Bermann