I would like to use the span slider from Qxt without having to install it. Is this possible?

后端 未结 1 1229
陌清茗
陌清茗 2021-01-20 12:07

I stumbled across a widget that provides you with a slider with two handles so you can select a range between an upper and lower limit.

I would like to use it withou

相关标签:
1条回答
  • 2021-01-20 13:05

    You need to add the following in the main class:

    private:
      QxtSpanSliderPrivate* d_ptr;
      friend class QxtSpanSliderPrivate;
    

    And in the following in the private class:

    private:
      QxtSpanSlider* q_ptr;
      friend class QxtSpanSlider;
    

    Also you should remove Qwt macros usage and replace qxt_d() and qxt_q() with direct access to q_ptr and d_ptr.

    Each constructor of the main class should initialize both pointers:

    QxtSpanSlider::QxtSpanSlider(Qt::Orientation orientation, QWidget* parent) :
      QSlider(orientation, parent), 
      d_ptr(new QxtSpanSliderPrivate())
    {
      d_ptr->q_ptr = this;
      //...
    }
    

    In case I forgot something, here is the gist. This code allowed me to successfully use QxtSpanSlider in Qt5.

    0 讨论(0)
提交回复
热议问题