PDA

View Full Version : Cannot import my graph



Stanfillirenfro
26th April 2014, 20:31
Hello!
I am facing the problem of importing my graph.
In the constructor of my window, I have the following code:

ui->customPlot->saveJpg(graphSName, 520, 520);

This work perfectly, but the image is saved in the same file with my executable.
The idea is to show a path to save the graph.
I have the following code:


void myMainwindow::save()
{
QString graphSName = QFileDialog::getSaveFileName(this, "Information", "Save", "Picture (*.jpg *.pdf. *png)");
saveGraph->setText(graphSName);

if(!graphSName.isEmpty())
{
saveGraphHere(graphSName);
}
}

void myMainWindow::saveGraphHere(QString &graphSName)
{
ui->customPlot->saveJpg(graphSName, 520, 520);
}

My connect is in the constructor of my MainWindow and as followed:

connect(saveButton, SIGNAL(clicked()), this, SLOT(save()));

The problem is that when I clicked on the saveButton, the program just crashes down.

I would be grateful to any help.

Many thanks in advance!

ChrisW67
26th April 2014, 21:25
It seems likely that the value of "saveGraph" at line 4 is null, uninitialised, or invalid. Running the program in your debugger and inspecting the backtrace will tell you for certain where it failed.

Stanfillirenfro
26th April 2014, 21:41
Many thanks ChrisW67!
Such a mistake!

Yes, I did not initialise "saveGraph".

The problem is solved.

Many thanks for your help!