Solved QCustomPlot integration with VS2017
-
Hi all and thanks for taking the time,
I use Qt with VS2017 and I try to integrate QCustomPlot. I can configure VS2017 to include the directive '#include "qcustomplot.h"' in the generated sources using the options for the ".ui" file in VS2017, but the logic in the generated code (based upon the ".ui" file) does not spawn an instance of QCustomPlot.
I tried to use Qt creator for that but without success.
Any thought will be much appreciated! -
Hi,
How exactly are you trying to use QCustomPlot in your application ?
-
Hi,
Thanks for replying.
The variable "ui" is an object provided by Qt, such as
private: Ui::SampleRenderer ui;
which is defined here (generated code):
(ui_SampleRenderer.h) namespace Ui { class SampleRenderer: public Ui_SampleRenderer {}; } // namespace Ui
which is turn is then included in my class:
#include "ui_SampleRenderer.h"
and finally
ui->plot->xAxis->setRange(0, 6, Qt::AlignCenter);
But the problem is that the member "plot" is not generated by VS2017, which is not surprising due to the fact that there is nothing in the ".ui" file to mandate it.
Can I use QCustomPlot separately?
Can you offer an alternative approach? -
In a sample provided by QCustomPlot I see in the "Ui_????" class:
void setupUi(QMainWindow *MainWindow) { ..... plot = new QCustomPlot(centralWidget);
But I don't have this code generated for me....
-
I followed the steps here:
https://www.qcustomplot.com/index.php/tutorials/settingup
To no avail - still, building my VS2017 project gives
Severity Code Description Project File Line Suppression State Error C2039 'plot': is not a member of 'Ui::SampleRenderer'
-
@tamirmichael said in QCustomPlot integration with VS2017:
But the problem is that the member "plot" is not generated by VS2017
So, you are using QtDesigner to design your UI - is that correct?
This "plot" variable will not be generated magically - you have to put it in QtDesigner like any other widget in order to be able to access it via ui->. -
Hi,
I followed the steps in the integration instructions as posted above but still, VS does not introduce the necessary code.
Maybe I missed a step - those are instructions for the Qt Creator, not designer:
https://www.qcustomplot.com/index.php/tutorials/settingup
But you referred to the designer. Can you please tell me how this can be done there as well? Thanks. -
@tamirmichael said in QCustomPlot integration with VS2017:
But you referred to the designer. Can you please tell me how this can be done there as well?
It's already done in the tutorial. See the "Promote to..." step.
-
OK thanks, will try later once I'm home....
-
Problem solved. Thanks for the timely support - much appreciated !