ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  QT+ChartDirect5.1 The background is not transparent
Posted by Jaker_IT on Mar-29-2018 16:59
When I set the background color for XYChart objects in QT, I added transparently. I saw that the color of the help document is ARGB format, so set the color value 0xFF01538d, but it is still not transparent, and see the color corresponding to 0x01538d. Please help me.
Here's my codeļ¼š
      XYChart *pChart = new XYChart(pChartViewer->width(), pChartViewer->height(), 0xFF01538d, 0x96FF0000, 1);

  Re: QT+ChartDirect5.1 The background is not transparent
Posted by Peter Kwan on Mar-29-2018 20:11
Hi Jaker,

When interpreted as ARGB color, the 0xFF01538d is totally transparent. So the RGB part 01538d does not matter. So in ChartDirector, only 0xFF000000 is used as the totally transparent color. The other 0xFFXXXXXX are reserved by ChartDirector to refer to other dynamically generated "magic" colors (such as gradient colors). See:

http://www.advsofteng.com/doc/cdcpp.htm#colorspec.htm

ChartDirector has a special constant Chart::Transparent to refer to the totally transparent color. The Chart::Transparent is the same as 0xFF000000.

So for your case, you may try:

      XYChart *pChart = new XYChart(pChartViewer->width(), pChartViewer->height(), Chart::Transparent, 0x96FF0000, 1);

Hope this can help.

Regards
Peter Kwan

  Re: QT+ChartDirect5.1 The background is not transparent
Posted by Jaker_IT on Mar-30-2018 15:52
I know that 0xFF01538d is completely transparent. What I want is transparent, but after I set up, I didn't achieve full transparency.

  Re: QT+ChartDirect5.1 The background is not transparent
Posted by Peter Kwan on Mar-30-2018 23:31
Hi Jaker,

I overlooked the "Subject" that mentioned you are using ChartDirector 5.1. In ChartDirector 5.x, Qt QChartViewer control itself is not transparent. So even the chart is transparent, it is put inside a control, it becomes non-transparent. The QChartViewer in this case will just ignore the "alpha channel".

The QChartViewer control is transparent in ChartDirector 6.x. May be you can consider to upgrade to the latest version.

Regards
Peter Kwan

  Re: QT+ChartDirect5.1 The background is not transparent
Posted by Jaker_IT on Mar-31-2018 17:41
Hi, peter

QChartViewer inherits QLabel, you can use QT stylesheet to set QChartViewer background transparency, so the QChartViewer you mentioned is not transparent, and I can't understand it.

Thank you for the reply

  Re: QT+ChartDirect5.1 The background is not transparent
Posted by Peter Kwan on Apr-01-2018 19:15
Hi Jaker,

You can modify the qchartviewer.cpp to make it support transparency. In qchartviewer.cpp, you should find a line:

MemBlock m = c->makeChart(Chart::BMP);

Please replace it with the following two lines. The QChartViewer will then support transparency.

c->setTransparentColor(-1);
MemBlock m = c->makeChart(Chart::PNG);


The BMP format is fast but normally is considered not to support transparency. In practice, some GUI frameworks extend the BMP format to support transparency, but they do it in different ways and there is no standard.

The PNG format supports transparency and it produces a "compressed" image, which is great if the image is to be transmitted through a network. However, "compression" and "decompression" is more CPU intensive than BMP.

The QChartViewer in ChartDirector 5.x was designed quite a while ago. To support fast realtime charts and track cursors, we decided to use the BMP format for performance. That's why the QChartViewer does not support transparency.

In ChartDirector 6.x, we have come up with a special undocumented format that is both fast and works for Qt. So it supports transparency.

I have just tested, and I think with the computers in the last 10 years, it should be fast enough to use the PNG format without noticible performance effect, so the above changes should work for your case.

Regards
Peter Kwan

  Re: QT+ChartDirect5.1 The background is not transparent
Posted by Jaker_IT on Apr-02-2018 09:55
Hi, peter

You've solved my problem perfectly.

thank you