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

Message ListMessage List     Post MessagePost Message

  Qt ChartViewer resize.
Posted by GCain on Oct-06-2012 09:40
Hi There,

I am using the QChartviewer with a finance chart in a Qt application.

Before I draw a chart the QChartviewer object resize correctly according to the layouts.

Once I draw a finance chart and resize the window, I cannot get the QChartviewer to
resize according to the layout. It appears to be fixed.

Is there a way I can force the QChartviewer to resize automatically, even if this gets done
on a redraw?

Thanks.

  Re: Qt ChartViewer resize.
Posted by Peter Kwan on Oct-09-2012 02:20
Hi GCain,

In the QChartViewer.cpp included in the same code, the QChartViewer is designed to assume the same size as the chart. For example, if you set the chart to 600 x 400 in size, the QChartViewer will be 600 x 400 in size. The code that does this in the QChartViewer.cpp is:

setFixedSize(c->getWidth(), c->getHeight());

Even if you can change the QChartViewer size, the chart inside the QChartViewer may still be at the same size. (The chart size is specified by your code when you create the chart.)

If your intention is to resize the chart, you may redraw the chart when the window resizes. There is an example in the following thread:

http://www.chartdir.com/forum/download_thread.php?site=chartdir&bn=chartdir_support&thread=1348560711#N1348860762

If your intention is not to resize the chart, but to resize the QChartViewer just for space filling purpose, then instead of resizing the QChartViewer, you can put the QChartViewer inside another widget, and resize that widget.

Hope this can help.

Regards
Peter Kwan

  Re: Qt ChartViewer resize.
Posted by GCain on Oct-11-2012 19:02
Thanks Peter.
I was hoping for a more 'native' solution, but that worked too.

Another questions quickly;

Whenever I delete a chartViewer after having drawn anything to it I get an access
violation in the QChartViewer.cpp in the destructor.

QChartViewer::~QChartViewer()
{
    delete m_hotSpotTester;
}

The error of course being MALLOC, freeing memory that was never initialized.

I am using GCC, Qt 4.8.1 on OSX.

Any suggestions on tracking this down. I haven't been able to find anything.

Thanks.

  Re: Qt ChartViewer resize.
Posted by GCain on Oct-11-2012 19:15
Please ignore this Peter.
I did a clean rebuild and the error seems to have magically gone away.

Thanks.