Results 1 to 3 of 3

Thread: Cannot import my graph

  1. #1
    Join Date
    Jan 2012
    Posts
    83
    Qt products
    Qt4
    Platforms
    Windows

    Default Cannot import my graph

    Hello!
    I am facing the problem of importing my graph.
    In the constructor of my window, I have the following code:
    Qt Code:
    1. ui->customPlot->saveJpg(graphSName, 520, 520);
    To copy to clipboard, switch view to plain text mode 

    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:

    Qt Code:
    1. void myMainwindow::save()
    2. {
    3. QString graphSName = QFileDialog::getSaveFileName(this, "Information", "Save", "Picture (*.jpg *.pdf. *png)");
    4. saveGraph->setText(graphSName);
    5.  
    6. if(!graphSName.isEmpty())
    7. {
    8. saveGraphHere(graphSName);
    9. }
    10. }
    11.  
    12. void myMainWindow::saveGraphHere(QString &graphSName)
    13. {
    14. ui->customPlot->saveJpg(graphSName, 520, 520);
    15. }
    To copy to clipboard, switch view to plain text mode 

    My connect is in the constructor of my MainWindow and as followed:
    Qt Code:
    1. connect(saveButton, SIGNAL(clicked()), this, SLOT(save()));
    To copy to clipboard, switch view to plain text mode 

    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!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Cannot import my graph

    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.

  3. #3
    Join Date
    Jan 2012
    Posts
    83
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Cannot import my graph

    Many thanks ChrisW67!
    Such a mistake!

    Yes, I did not initialise "saveGraph".

    The problem is solved.

    Many thanks for your help!

Similar Threads

  1. How to create own graph(Curve graph) using Qt ?
    By karankumar1609 in forum Qt Programming
    Replies: 3
    Last Post: 11th July 2013, 12:48
  2. Qt 4.5 import stylesheet
    By dcoppenb in forum Qt Programming
    Replies: 0
    Last Post: 7th March 2013, 13:47
  3. import pdf in a QGraphicsView
    By tilsitt in forum Qt Programming
    Replies: 1
    Last Post: 25th March 2011, 17:18
  4. Import dll problems
    By tom0485 in forum Qt Programming
    Replies: 7
    Last Post: 25th May 2010, 08:47
  5. How do i import and use a DLL like Skype4COM.dll in Qt4?
    By fernando in forum Qt Programming
    Replies: 3
    Last Post: 8th May 2010, 08:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.