#640 Make QtGnuplotWidget easier reusable

None
closed-accepted
nobody
None
5
2013-12-11
2013-10-22
Thomas Bleher
No

QtGnuplotWidget can be used to embed Gnuplot into an existing Qt application. This patch makes integration easier, through the following changes:

  • QtGnuplotWidget gets the parent QWidget pointer as its first parameter. With this change, QtGnuplotWidget can be loaded from ui files.
  • The export functions in QtGnuplotWidget get the target filename from a parameter, and do not ask for it themselves. This enables the embedding application to query for the filename in some other way.
  • loadSettings and saveSettings can use a configurable path for their settings. Thus it is possible to have e.g. several plots with different settings.

The behaviour of Gnuplot is unchanged.

1 Attachments

Discussion

  • Ethan Merritt
    Ethan Merritt
    2013-11-14

    I'm just getting to this one now. Sorry for the delay.

    The patch applies cleanly and gnuplot itself works fine for me when built against Qt4. But I have a question. The patch does not modify the demo program source in qtterminal/embed_example.cpp yet the demo nevertheless builds and works. Why? I would have expected that the demo would need to have the calls to QtGnuplotWidget modified appropriately.

    In contrast, the demo does not build with Qt5. I get errors like this:

    qtterminal/embed_example.h:55:30: error: invalid use of incomplete type class QWidget
    /usr/lib/qt5/include/QtCore/qmetatype.h:429:7: error: forward declaration of ‘class QWidget’
    qtterminal/embed_example.cpp:50:4: error: type QWidget is not a direct base of GnuplotWidget
    qtterminal/embed_example.cpp:56:104: error: connect was not declared in this scope
    qtterminal/embed_example.cpp:61:44: error: no matching function for call to QVBoxLayout::QVBoxLayout(GnuplotWidget* const)
    qtterminal/embed_example.cpp:64:39: error: no matching function for call to QPlainTextEdit::QPlainTextEdit(GnuplotWidget* const)
    qtterminal/embed_example.cpp:71:18: error: setLayout was not declared in this scope
    qtterminal/embed_example.cpp:72:95: error: connect was not declared in this scope
    qtterminal/embed_example.cpp:95:55: error: connect was not declared in this scope
    qtterminal/embed_example.cpp:121:37: error: no matching function for call to QMainWindow::setCentralWidget(GnuplotWidget*&)
    

    I hasten to add that I get more or less the same errors even without applying this patch, so it's not that the patch breaks the demo. The point is just that the demo code may need some attention anyhow. Do you want to have a look at it?

     
  • Thomas Bleher
    Thomas Bleher
    2013-11-23

    Sorry for my late answer - was pretty busy the last days.
    I see that you already fixed the compile error on Qt5.

    As to changes needed for embed_example: the example is quite simple and doesn't use any of more advanced features like printing, saving files and so on. It doesn't use any of the functions I modified, thus needs no changes to match.

     
  • Ethan Merritt
    Ethan Merritt
    2013-12-11

    • status: open --> closed-accepted
    • Group: -->