[SOLVED] Return a QString maybe a C++ question
-
Hi
i wanna return a QString fileName from on_pushButton_clicked() to on_commandLinkButton_clicked()
With on_pushButton_clicked() i get my filename to open.
In on_commandLinkButton_clicked() process the fileWhat do i have to do. I tried severel snippet from google but i am a complete C++ beginner an have no idea..
@
void EngMountStiff::on_pushButton_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "",tr("Nastran Punch Files (.pch);;ALL Files (.*)"));
}
void EngMountStiff::on_commandLinkButton_clicked()
{
QString aScript = "print ""+fileName+"\n";";
.
.
.
}
@Thanks
-
You should define(?) a QString inside your class (header file)
@class EngMountStiff
{
//whatever is added hereprivate: //i prefer it private, depends on you QString fileName;
}@
then you may use it in your classes like this:
@void EngMountStiff::on_pushButton_clicked()
{
/Notice the minor change here/
fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "",tr("Nastran Punch Files (.pch);;ALL Files (.*)"));
}
void EngMountStiff::on_commandLinkButton_clicked()
{
QString aScript = "print ""+fileName+"\n";";
.
.
.
}@