Results 1 to 4 of 4

Thread: QwtDateScaleDraw understading

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2016
    Posts
    8
    Thanks
    2

    Default Re: QwtDateScaleDraw understading

    Hi,

    Thank you very much for your reply.

    I have a main window which I have used showMaximized on.
    Qt Code:
    1. ui->setupUi(this);
    2. this->showMaximized();
    To copy to clipboard, switch view to plain text mode 
    I've have then added two main items :
    a scrollArea and a tabWidget
    Qt Code:
    1. QScrollArea* scrollArea = new QScrollArea;
    2. ui->layout->addWidget(scrollArea,1,0,1,4);
    3. //The tabWidget is created in Designer but filled with line codes and I have placed it for it to fill the rows I wanted
    4. ui->layout->addWidget(ui->tabWidget,1,5,1,9);
    To copy to clipboard, switch view to plain text mode 

    I have one of the tabs that contains my plot (and 4 buttons).
    Qt Code:
    1. layoutTab1->addWidget(button1,0,0);
    2. layoutTab1->addWidget(button2,0,1);
    3. layoutTab1->addWidget(button3,0,2);
    4. layoutTab1->addWidget(button4,0,3);
    5. layoutTab1->addWidget(myPlot,2,0,1,5);
    6. ui->tab1->setLayout(layoutTab1);
    To copy to clipboard, switch view to plain text mode 
    I have tried to put sizeConstraint on my layoutTab1 but it had no effect, and a sizeFixed on my mainLayout didn't do the trick either.

    I don't know if it's relevant for my problem, but I need to display different plots depending on the button choosed, so I've put all my plots on the same place and hide/show them when a button is clicked.

    I have now added curves to my plot but I still have this issue with my date format and my scale engine. I m aware that I'm probably doing it wrong, but as I said earlyer this one of my first Qt Project. Sorry if I'm still missing informations.

    Thanks for your help,

    Stank

  2. #2
    Join Date
    May 2016
    Posts
    8
    Thanks
    2

    Default Re: QwtDateScaleDraw understading

    This is not the solution i was aiming for but it worked :

    I solved my scale problem at the same time as my format problem using this method :
    (original post in french) : http://www.developpez.net/forums/d10...-axe-absisses/
    overight the QwtText label function :

    Qt Code:
    1. class TimeScaleDraw: public QwtScaleDraw
    2. {
    3. virtual QwtText label(double v) const
    4. {
    5. QDateTime t = QDateTime::fromTime_t((int)v); //cf fromTime_t
    6. return t.toString("dd/MM/yyyy");
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

    and then
    Qt Code:
    1. myPlot->setAxisScaleDraw(QwtPlot::xBottom, new TimeScaleDraw());
    2. myPlot->setAxisScale(QwtPlot::xBottom, min, max);
    To copy to clipboard, switch view to plain text mode 
    where min and max are values in second since epoch.

    Thanks for your time

    Stank

Similar Threads

  1. Replies: 3
    Last Post: 1st February 2016, 08:04
  2. Replies: 1
    Last Post: 14th October 2015, 07:29

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.