Results 1 to 3 of 3

Thread: Change Title of graph or axis

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2015
    Posts
    50
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Change Title of graph or axis

    Hi,

    in my app i plot a graph. The user can choose which data he wants to plot. I want that the user has the choice to change the title of the graph and axis. So I added a settingsdialog where you can type the title in a Textedit.

    Qt Code:
    1. void graphsettingsdialog::on_ApplySettings_clicked(){
    2. ...
    3. QString titlexax=ui->TitleXAxEdit->text();
    4.  
    5. PlotDialog->setxAxisTitle(titlexax);
    6. ...
    7. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void MonitorPlotWindow::setxAxisTitle(QString m_title){
    2. livePlot->setAxisTitle(livePlot->xBottom, m_title);
    3. qDebug() << "set Title" << livePlot->axisTitle(livePlot->xBottom).text();
    4. }
    To copy to clipboard, switch view to plain text mode 

    The qDebug() gives me the title I choosed but the plot still has the same title for the x-axe. I tried to replot and close and open the livePlot (livePlot->close(); livePlot->setAxisTitle(livePlot->xBottom, m_title); livePlot->open() but this had no effect.

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Change Title of graph or axis

    The posted code is correct and the axis title should updated without any further steps. So I guess there is something wrong in your application - maybe a different plot ?

    Uwe

  3. #3
    Join Date
    Oct 2015
    Posts
    50
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Change Title of graph or axis

    It seems like I do something basic wrong.
    I have a Window MonitorPlotWindow in its constructor i call

    Qt Code:
    1. MonitorPlotWindow::MonitorPlotWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MonitorPlotWindow)
    4. {
    5. ui->setupUi(this);
    6. SetupPlot();
    7. }
    To copy to clipboard, switch view to plain text mode 

    SetupPlot looks like this.

    Qt Code:
    1. void MonitorPlotWindow::SetupPlot(){
    2. livePlot = new QwtPlot(ui->centralwidget);
    3. ui->horizontalLayout->addWidget(livePlot);
    4.  
    5. QwtPlotGrid *liveGrid = new QwtPlotGrid();
    6. liveGrid->attach(livePlot);
    7.  
    8. QwtPlotPanner *plotPanner = new QwtPlotPanner(livePlot->canvas());
    9.  
    10. QwtPlotMagnifier *plotMagnifier = new QwtPlotMagnifier(livePlot->canvas());
    11.  
    12. livePlot->setCanvasBackground(Qt::white);
    13.  
    14. QwtLegend *legend = new QwtLegend;
    15. legend->setFrameStyle(QFrame::Box|QFrame::Sunken);
    16. livePlot->insertLegend(legend, QwtPlot::BottomLegend);
    17. livePlot->detachItems(QwtPlotItem::Rtti_PlotLegend, true);
    18. }
    To copy to clipboard, switch view to plain text mode 

    From another Window I call
    Qt Code:
    1. void MonitorWindow::on_actionShow_triggered(){
    2. Plot->show();
    3. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void MonitorWindow::allocateMemory(){
    2. Plot = new MonitorPlotWindow(this);
    3. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Rotating Y Axis Title
    By bigjoeystud in forum Qwt
    Replies: 3
    Last Post: 9th June 2015, 20:57
  2. Axis Title to axis label alignment
    By ROCKSTAR in forum Qwt
    Replies: 0
    Last Post: 5th February 2014, 12:47
  3. how rotate axis title
    By Andell in forum Qwt
    Replies: 2
    Last Post: 1st October 2012, 00:11
  4. QwtPlot Change Axis Title Alignment
    By deepy in forum Qwt
    Replies: 5
    Last Post: 20th October 2010, 13:40
  5. Set axis title on the right side
    By pospiech in forum Qwt
    Replies: 1
    Last Post: 14th March 2008, 07:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.