|
change background image of realtimezoomscroll |
Posted by isan on Jul-18-2018 00:08 |
|
Hi, I use realtimezoomscroll with qt language , and I want to add image to background after line 374 in realtimezoomscroll.cpp
c->setPlotArea(55, 50, c->getWidth() - 85, c->getHeight() - 80, c->linearGradientColor(0, 50, 0, c->getHeight() - 35, 0xf0f6ff, 0xa0c0ff), -1, Chart::Transparent, 0xffffff, 0xffffff);
I add this line
c->setWallpaper(":/new/prefix1/ECG_Paper.png");
and it doesn't work,I want the grid line to continue to be shown!
how to add background image and show grid line? |
Re: change background image of realtimezoomscroll |
Posted by Peter Kwan on Jul-19-2018 01:16 |
|
HI isan,
The path you use begins with ":/". It seems to be a Qt resource path.
The current version of ChartDirector supports only file system paths (that is, the type of path you use to load a file from the hard disk). In our sample code, we usually put the image files in the same directory as the EXE and just use "ECG_Paper.png" as the path name.
The next minor release of ChartDirector (version 6.3) will support resources, including Qt resources. The updated DLL are mostly completely and we are now developing the sample code and documentation. If you would like to use Qt resources, I can ask our developer to send you the new DLL so you can use Qt resource paths.
Regards
Peter Kwan |
Re: change background image of realtimezoomscroll |
Posted by isan on Jul-19-2018 01:42 |
|
thank you , but for pushbutton icon I use qt path and it's work
instead of this
QPushButton *pointerPB = new QPushButton(QIcon(":/pointer.png"), "Pointer", frame);
I use this
QPushButton *pointerPB = new QPushButton(QIcon(":/new/prefix1/pointer.png"), "Pointer", frame);
realtimezoomscroll has resource file, I think we can copy the path in qt!
I put the image files in the same directory as the EXE and program file
but when run the chart background doesn't change
I use the right command to change the chart background? is it in the right place? |
Re: change background image of realtimezoomscroll |
Posted by Peter Kwan on Jul-19-2018 19:47 |
|
Hi isan,
I tried myself, and found that in my Qt on Windows, the "Qt Creator" will put the "realtimezoomscroll.exe" in a directory "build-realtimezoomscroll-Desktop_Qt_5_6_0_MinGW_32bit-Debug". So if the code is run in the "Qt Creator", the image file "ECG_Paper.png" would need to be in that directory too.
I have modified the Qt project file "realtimezoomscroll.pro" so that the "Qt Creator" will now put the "realtimezoomscroll.exe" in the same directory as the source code (that is, in the "realtimezoomscroll" directory). In this way, you can just put the "ECG_Paper.png" in the source code directory. I have attached the entire modified "realtimezoomscroll" Qt project for your reference, with the code modified to include a wallpaper. Please download it to try it. (Use the files inside to replace the files in the original "realtimezoomscroll" sample code.)
For the Qt resource path, it is supported by controls that come with Qt, such as QPushButton and QIcon. ChartDirector is a third party control, and the current version does not support Qt resource. If you want to use Qt resource, I can ask our developer to send the DLL for the next version to you, which supports Qt resources.
Regards
Peter Kwan
|
Re: change background image of realtimezoomscroll |
Posted by isan on Jul-19-2018 22:56 |
|
Thank you for your response ,It's worked but it's change the window background
I want to change the chart background (its from light blue to sky blue in default)
I asked before `I use the right command to change the chart background` ?Misunderstanding has happened!
I did not say it clearly! sorry! |
Re: change background image of realtimezoomscroll |
Posted by Peter Kwan on Jul-20-2018 00:12 |
|
Hi isan,
In ChartDirector terminology, that part is called the "plot area". If you want to set a "wallpaper" to the plot area, you can change the existing setPlotArea line to the followings:
c->setPlotArea(55, 50, c->getWidth() - 85, c->getHeight() - 80, c->patternColor("rock.png"), -1, Chart::Transparent, 0xffffff, 0xffffff);
If what you need is a background image, it is like:
PlotArea *p = c->setPlotArea(55, 50, c->getWidth() - 85, c->getHeight() - 80, -1, -1, Chart::Transparent, 0xffffff, 0xffffff);
p->setBackground("rock.png");
(A wallpaper is an image that will repeat itself to fill the region. A background image is an image only appears and will not repeat itself.)
Regards
Peter Kwan |
Re: change background image of realtimezoomscroll |
Posted by isan on Jul-20-2018 04:29 |
|
thank you so much! |
|