PDA

View Full Version : axis text management



kpr
22nd February 2011, 15:19
I've got a function like this:

void PlotWindow::setXAxisTitle (QString & name)
{
setAxisTitle(QwtPlot::xBottom, name);
axisTitle(QwtPlot::xBottom).setRenderFlags(Qt::Ali gnRight);
axisTitle(QwtPlot::xBottom).setText("name2",QwtText::RichText);
}

The first line works and puts (center aligned) name "name" to X axis. But the following lines, used for put title right aligned an change title text don't work! i don't understand why, any help?

Thanks

Uwe
22nd February 2011, 20:41
setAxisTitle(QwtPlot::xBottom, name);
axisTitle(QwtPlot::xBottom).setRenderFlags(Qt::Ali gnRight);
axisTitle(QwtPlot::xBottom).setText("name2",QwtText::RichText);
Of course this doesn't work - this code is manipulating the return value of a function. Instead you have to write it this way:


QwtText text( "name2", QwtText::RichText );
text.setRenderFlags(Qt::AlignRight);
setAxisTitle(xBottom, text );Uwe

kpr
23rd February 2011, 10:41
Cool, now it's works, thanks!