QCustomPlot integration with VS2017
-
wrote on 16 Apr 2019, 19:38 last edited by
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 ?
-
wrote on 17 Apr 2019, 02:55 last edited by
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? -
wrote on 17 Apr 2019, 03:33 last edited by
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....
-
wrote on 17 Apr 2019, 04:05 last edited by tamirmichael
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'
-
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?@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->. -
wrote on 17 Apr 2019, 06:27 last edited by tamirmichael
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. -
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.
-
wrote on 17 Apr 2019, 07:02 last edited by
OK thanks, will try later once I'm home....
-
wrote on 17 Apr 2019, 17:16 last edited by
Problem solved. Thanks for the timely support - much appreciated !
1/10