Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] QSlider with timestamps
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QSlider with timestamps

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 3.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    QtYury
    wrote on last edited by
    #1

    Hello friends!

    I want to add timestamps above slider widget.
    !http://s7.postimg.org/b6rj8xcq3/timeline2.png!
    Center of each label exactly matches with the time on the slider.

    What is the simplest way to archive this?

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      you can give "QwtSlider":http://qwt.sourceforge.net a try if thats an option for you.
      See "here":http://www.qtcentre.org/threads/51004-Customize-tick-labels-in-a-QwtSlider how to do so.

      If not and you want to stick to Qt libraries only. You will need to override the paintEvent() method of QSlider and replace the text of the ticks with your desired values. See Qt sources for reference.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        QtYury
        wrote on last edited by
        #3

        Thank you, raven-worx!
        I'll try QwtSlider right now.

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          QtYury
          wrote on last edited by
          #4

          QwtSlider works perfectly. Maybe someone will need the code:

          @
          QwtDateScaleDraw *dsd = new QwtDateScaleDraw();
          dsd->setDateFormat(QwtDate::Millisecond, "hh:mm");
          dsd->setDateFormat(QwtDate::Second, "hh:mm");
          dsd->setDateFormat(QwtDate::Minute, "hh:mm");
          dsd->setDateFormat(QwtDate::Hour, "hh:mm");

          slider = new QwtSlider(Qt::Horizontal, this);
          slider->setSpacing(0);
          slider->setTotalSteps(600);
          slider->setPageSteps(60);
          slider->setScale(
          1000.0QDateTime(QDate(2013, 9, 2), QTime(15, 0)).toTime_t(),
          1000.0
          QDateTime(QDate(2013, 9, 2), QTime(15, 10)).toTime_t()
          );
          slider->setScaleStepSize(60000);
          slider->setScaleMaxMajor(10);
          slider->setScaleDraw(dsd);
          slider->setHandleSize(QSize(20, 10));
          @

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved