ctkDoubleRangeSlider.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.commontk.org/LICENSE
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. // Qt includes
  15. #include <QDebug>
  16. #include <QHBoxLayout>
  17. // CTK includes
  18. #include "ctkRangeSlider.h"
  19. #include "ctkDoubleRangeSlider.h"
  20. //-----------------------------------------------------------------------------
  21. class ctkDoubleRangeSliderPrivate
  22. {
  23. Q_DECLARE_PUBLIC(ctkDoubleRangeSlider);
  24. protected:
  25. ctkDoubleRangeSlider* const q_ptr;
  26. public:
  27. ctkDoubleRangeSliderPrivate(ctkDoubleRangeSlider& object);
  28. int toInt(double _value)const;
  29. double minFromInt(int _value)const;
  30. double maxFromInt(int _value)const;
  31. void init();
  32. void connectSlider();
  33. void updateMinOffset(double value);
  34. void updateMaxOffset(double value);
  35. ctkRangeSlider* Slider;
  36. double Minimum;
  37. double Maximum;
  38. bool SettingRange;
  39. // we should have a MinValueOffset and MinPositionOffset (and MinimumOffset?)
  40. double MinOffset;
  41. // we should have a MaxValueOffset and MaxPositionOffset (and MaximumOffset?)
  42. double MaxOffset;
  43. double SingleStep;
  44. double MinValue;
  45. double MaxValue;
  46. };
  47. // --------------------------------------------------------------------------
  48. ctkDoubleRangeSliderPrivate::ctkDoubleRangeSliderPrivate(ctkDoubleRangeSlider& object)
  49. :q_ptr(&object)
  50. {
  51. // the initial values will be overwritten in
  52. // ctkDoubleRangeSliderPrivate::init()
  53. this->Slider = 0;
  54. this->Minimum = 0.;
  55. this->Maximum = 99.;
  56. this->SettingRange = false;
  57. this->MinOffset = 0.;
  58. this->MaxOffset = 0.;
  59. this->SingleStep = 1.;
  60. this->MinValue = 0.;
  61. this->MaxValue = 99.;
  62. }
  63. // --------------------------------------------------------------------------
  64. void ctkDoubleRangeSliderPrivate::init()
  65. {
  66. Q_Q(ctkDoubleRangeSlider);
  67. this->Slider = new ctkRangeSlider(q);
  68. QHBoxLayout* l = new QHBoxLayout(q);
  69. l->addWidget(this->Slider);
  70. l->setContentsMargins(0,0,0,0);
  71. this->Minimum = this->Slider->minimum();
  72. this->Maximum = this->Slider->maximum();
  73. this->MinValue = this->Slider->minimumValue();
  74. this->MaxValue = this->Slider->maximumValue();
  75. this->SingleStep = this->Slider->singleStep();
  76. q->setSizePolicy(this->Slider->sizePolicy());
  77. q->setAttribute(Qt::WA_WState_OwnSizePolicy, false);
  78. this->connectSlider();
  79. }
  80. // --------------------------------------------------------------------------
  81. void ctkDoubleRangeSliderPrivate::connectSlider()
  82. {
  83. Q_Q(ctkDoubleRangeSlider);
  84. q->connect(this->Slider, SIGNAL(valuesChanged(int,int)),
  85. q, SLOT(onValuesChanged(int,int)));
  86. q->connect(this->Slider, SIGNAL(minimumPositionChanged(int)),
  87. q, SLOT(onMinPosChanged(int)));
  88. q->connect(this->Slider, SIGNAL(maximumPositionChanged(int)),
  89. q, SLOT(onMaxPosChanged(int)));
  90. q->connect(this->Slider, SIGNAL(positionsChanged(int,int)),
  91. q, SLOT(onPositionsChanged(int,int)));
  92. q->connect(this->Slider, SIGNAL(sliderPressed()),
  93. q, SIGNAL(sliderPressed()));
  94. q->connect(this->Slider, SIGNAL(sliderReleased()),
  95. q, SIGNAL(sliderReleased()));
  96. q->connect(this->Slider, SIGNAL(rangeChanged(int, int)),
  97. q, SLOT(onRangeChanged(int, int)));
  98. }
  99. // --------------------------------------------------------------------------
  100. int ctkDoubleRangeSliderPrivate::toInt(double doubleValue)const
  101. {
  102. double tmp = doubleValue / this->SingleStep;
  103. int intValue = qRound(tmp);
  104. return intValue;
  105. }
  106. // --------------------------------------------------------------------------
  107. double ctkDoubleRangeSliderPrivate::minFromInt(int intValue)const
  108. {
  109. double doubleValue = this->SingleStep * (this->MinOffset + intValue) ;
  110. return doubleValue;
  111. }
  112. // --------------------------------------------------------------------------
  113. double ctkDoubleRangeSliderPrivate::maxFromInt(int intValue)const
  114. {
  115. double doubleValue = this->SingleStep * (this->MaxOffset + intValue) ;
  116. return doubleValue;
  117. }
  118. // --------------------------------------------------------------------------
  119. void ctkDoubleRangeSliderPrivate::updateMinOffset(double value)
  120. {
  121. this->MinOffset = (value / this->SingleStep) - this->toInt(value);
  122. }
  123. // --------------------------------------------------------------------------
  124. void ctkDoubleRangeSliderPrivate::updateMaxOffset(double value)
  125. {
  126. this->MaxOffset = (value / this->SingleStep) - this->toInt(value);
  127. }
  128. // --------------------------------------------------------------------------
  129. ctkDoubleRangeSlider::ctkDoubleRangeSlider(QWidget* _parent) : Superclass(_parent)
  130. , d_ptr(new ctkDoubleRangeSliderPrivate(*this))
  131. {
  132. Q_D(ctkDoubleRangeSlider);
  133. d->init();
  134. }
  135. // --------------------------------------------------------------------------
  136. ctkDoubleRangeSlider::ctkDoubleRangeSlider(Qt::Orientation _orientation, QWidget* _parent)
  137. : Superclass(_parent)
  138. , d_ptr(new ctkDoubleRangeSliderPrivate(*this))
  139. {
  140. Q_D(ctkDoubleRangeSlider);
  141. d->init();
  142. this->setOrientation(_orientation);
  143. }
  144. // --------------------------------------------------------------------------
  145. ctkDoubleRangeSlider::~ctkDoubleRangeSlider()
  146. {
  147. }
  148. // --------------------------------------------------------------------------
  149. void ctkDoubleRangeSlider::setMinimum(double min)
  150. {
  151. Q_D(ctkDoubleRangeSlider);
  152. double oldMin = d->Minimum;
  153. d->Minimum = min;
  154. if (d->Minimum >= d->MinValue)
  155. {// TBD: use same offset
  156. d->updateMinOffset(d->Minimum);
  157. }
  158. if (d->Minimum >= d->MaxValue)
  159. {// TBD: use same offset
  160. d->updateMaxOffset(d->Minimum);
  161. }
  162. d->SettingRange = true;
  163. d->Slider->setMinimum(d->toInt(min));
  164. d->SettingRange = false;
  165. if (d->Minimum != oldMin)
  166. {
  167. emit this->rangeChanged(d->Minimum, d->Maximum);
  168. }
  169. }
  170. // --------------------------------------------------------------------------
  171. double ctkDoubleRangeSlider::minimum()const
  172. {
  173. Q_D(const ctkDoubleRangeSlider);
  174. return d->Minimum;
  175. }
  176. // --------------------------------------------------------------------------
  177. void ctkDoubleRangeSlider::setMaximum(double max)
  178. {
  179. Q_D(ctkDoubleRangeSlider);
  180. double oldMax = d->Maximum;
  181. d->Maximum = max;
  182. if (d->Maximum <= d->MinValue)
  183. {// TBD: use same offset
  184. d->updateMinOffset(d->Maximum);
  185. }
  186. if (d->Maximum <= d->MaxValue)
  187. {// TBD: use same offset ?
  188. d->updateMaxOffset(d->Maximum);
  189. }
  190. d->SettingRange = true;
  191. d->Slider->setMaximum(d->toInt(max));
  192. d->SettingRange = false;
  193. if (d->Maximum != oldMax)
  194. {
  195. emit this->rangeChanged(d->Minimum, d->Maximum);
  196. }
  197. }
  198. // --------------------------------------------------------------------------
  199. double ctkDoubleRangeSlider::maximum()const
  200. {
  201. Q_D(const ctkDoubleRangeSlider);
  202. return d->Maximum;
  203. }
  204. // --------------------------------------------------------------------------
  205. void ctkDoubleRangeSlider::setRange(double min, double max)
  206. {
  207. Q_D(ctkDoubleRangeSlider);
  208. double oldMin = d->Minimum;
  209. double oldMax = d->Maximum;
  210. d->Minimum = min;
  211. d->Maximum = max;
  212. if (d->Minimum >= d->MinValue)
  213. {// TBD: use same offset
  214. d->updateMinOffset(d->Minimum);
  215. }
  216. if (d->Minimum >= d->MaxValue)
  217. {// TBD: use same offset
  218. d->updateMaxOffset(d->Minimum);
  219. }
  220. if (d->Maximum <= d->MinValue)
  221. {// TBD: use same offset
  222. d->updateMinOffset(d->Maximum);
  223. }
  224. if (d->Maximum <= d->MaxValue)
  225. {// TBD: use same offset ?
  226. d->updateMaxOffset(d->Maximum);
  227. }
  228. d->SettingRange = true;
  229. d->Slider->setRange(d->toInt(min), d->toInt(max));
  230. d->SettingRange = false;
  231. if (d->Minimum != oldMin || d->Maximum != oldMax)
  232. {
  233. emit this->rangeChanged(d->Minimum, d->Maximum);
  234. }
  235. }
  236. // --------------------------------------------------------------------------
  237. double ctkDoubleRangeSlider::minimumPosition()const
  238. {
  239. Q_D(const ctkDoubleRangeSlider);
  240. return d->minFromInt(d->Slider->minimumPosition());
  241. }
  242. // --------------------------------------------------------------------------
  243. void ctkDoubleRangeSlider::setMinimumPosition(double minPos)
  244. {
  245. Q_D(ctkDoubleRangeSlider);
  246. d->Slider->setMinimumPosition(d->toInt(minPos));
  247. }
  248. // --------------------------------------------------------------------------
  249. double ctkDoubleRangeSlider::maximumPosition()const
  250. {
  251. Q_D(const ctkDoubleRangeSlider);
  252. return d->maxFromInt(d->Slider->maximumPosition());
  253. }
  254. // --------------------------------------------------------------------------
  255. void ctkDoubleRangeSlider::setMaximumPosition(double maxPos)
  256. {
  257. Q_D(ctkDoubleRangeSlider);
  258. d->Slider->setMaximumPosition(d->toInt(maxPos));
  259. }
  260. // --------------------------------------------------------------------------
  261. void ctkDoubleRangeSlider::setPositions(double minPos, double maxPos)
  262. {
  263. Q_D(ctkDoubleRangeSlider);
  264. d->Slider->setPositions(d->toInt(minPos), d->toInt(maxPos));
  265. }
  266. // --------------------------------------------------------------------------
  267. double ctkDoubleRangeSlider::minimumValue()const
  268. {
  269. Q_D(const ctkDoubleRangeSlider);
  270. return d->MinValue;
  271. }
  272. // --------------------------------------------------------------------------
  273. void ctkDoubleRangeSlider::setMinimumValue(double newMinValue)
  274. {
  275. Q_D(ctkDoubleRangeSlider);
  276. newMinValue = qBound(d->Minimum, newMinValue, d->Maximum);
  277. d->updateMinOffset(newMinValue);
  278. if (newMinValue >= d->MaxValue)
  279. {
  280. d->updateMaxOffset(newMinValue);
  281. }
  282. int newIntValue = d->toInt(newMinValue);
  283. if (newIntValue != d->Slider->minimumValue())
  284. {
  285. // d->Slider will emit a minimumValueChanged signal that is connected to
  286. // ctkDoubleSlider::onValueChanged
  287. d->Slider->setMinimumValue(newIntValue);
  288. }
  289. else
  290. {
  291. double oldValue = d->MinValue;
  292. d->MinValue = newMinValue;
  293. // don't emit a valuechanged signal if the new value is quite
  294. // similar to the old value.
  295. if (qAbs(newMinValue - oldValue) > (d->SingleStep * 0.000000001))
  296. {
  297. emit this->valuesChanged(newMinValue, this->maximumValue());
  298. emit this->minimumValueChanged(newMinValue);
  299. }
  300. }
  301. }
  302. // --------------------------------------------------------------------------
  303. double ctkDoubleRangeSlider::maximumValue()const
  304. {
  305. Q_D(const ctkDoubleRangeSlider);
  306. return d->MaxValue;
  307. }
  308. // --------------------------------------------------------------------------
  309. void ctkDoubleRangeSlider::setMaximumValue(double newMaxValue)
  310. {
  311. Q_D(ctkDoubleRangeSlider);
  312. newMaxValue = qBound(d->Minimum, newMaxValue, d->Maximum);
  313. d->updateMaxOffset(newMaxValue);
  314. if (newMaxValue <= d->MinValue)
  315. {
  316. d->updateMinOffset(newMaxValue);
  317. }
  318. int newIntValue = d->toInt(newMaxValue);
  319. if (newIntValue != d->Slider->maximumValue())
  320. {
  321. // d->Slider will emit a maximumValueChanged signal that is connected to
  322. // ctkDoubleSlider::onValueChanged
  323. d->Slider->setMaximumValue(newIntValue);
  324. }
  325. else
  326. {
  327. double oldValue = d->MaxValue;
  328. d->MaxValue = newMaxValue;
  329. // don't emit a valuechanged signal if the new value is quite
  330. // similar to the old value.
  331. if (qAbs(newMaxValue - oldValue) > (d->SingleStep * 0.000000001))
  332. {
  333. emit this->valuesChanged(this->minimumValue(), newMaxValue);
  334. emit this->maximumValueChanged(newMaxValue);
  335. }
  336. }
  337. }
  338. // --------------------------------------------------------------------------
  339. void ctkDoubleRangeSlider::setValues(double newMinVal, double newMaxVal)
  340. {
  341. Q_D(ctkDoubleRangeSlider);
  342. // We can't call setMinimumValue() and setMaximumValue() as they would
  343. // generate an inconsistent state. when minimumValueChanged() is fired the
  344. // new max value wouldn't be updated yet.
  345. double newMinValue = qBound(d->Minimum, qMin(newMinVal, newMaxVal), d->Maximum);
  346. double newMaxValue = qBound(d->Minimum, qMax(newMinVal, newMaxVal), d->Maximum);
  347. d->updateMinOffset(newMinValue);
  348. d->updateMaxOffset(newMaxValue);
  349. int newMinIntValue = d->toInt(newMinValue);
  350. int newMaxIntValue = d->toInt(newMaxValue);
  351. if (newMinIntValue != d->Slider->minimumValue() ||
  352. newMaxIntValue != d->Slider->maximumValue())
  353. {
  354. // d->Slider will emit a maximumValueChanged signal that is connected to
  355. // ctkDoubleSlider::onValueChanged
  356. d->Slider->setValues(newMinIntValue, newMaxIntValue);
  357. }
  358. else
  359. {
  360. double oldMinValue = d->MinValue;
  361. double oldMaxValue = d->MaxValue;
  362. d->MinValue = newMinValue;
  363. d->MaxValue = newMaxValue;
  364. // don't emit a valuechanged signal if the new value is quite
  365. // similar to the old value.
  366. bool minChanged = qAbs(newMinValue - oldMinValue) > (d->SingleStep * 0.000000001);
  367. bool maxChanged = qAbs(newMaxValue - oldMaxValue) > (d->SingleStep * 0.000000001);
  368. if (minChanged || maxChanged)
  369. {
  370. emit this->valuesChanged(newMinValue, newMaxValue);
  371. if (minChanged)
  372. {
  373. emit this->minimumValueChanged(newMinValue);
  374. }
  375. if (maxChanged)
  376. {
  377. emit this->maximumValueChanged(newMaxValue);
  378. }
  379. }
  380. }
  381. }
  382. // --------------------------------------------------------------------------
  383. double ctkDoubleRangeSlider::singleStep()const
  384. {
  385. Q_D(const ctkDoubleRangeSlider);
  386. return d->SingleStep;
  387. }
  388. // --------------------------------------------------------------------------
  389. void ctkDoubleRangeSlider::setSingleStep(double newStep)
  390. {
  391. Q_D(ctkDoubleRangeSlider);
  392. d->SingleStep = newStep;
  393. // The following can fire A LOT of signals that shouldn't be
  394. // fired.
  395. bool oldBlockSignals = this->blockSignals(true);
  396. d->updateMinOffset(d->MinValue);
  397. d->updateMaxOffset(d->MaxValue);
  398. // update the new values of the ctkRangeSlider
  399. double _minvalue = d->MinValue;
  400. double _maxvalue = d->MaxValue;
  401. // calling setMinimum or setMaximum can change the values MinimumValue
  402. // and MaximumValue, this is why we re-set them later.
  403. this->setMinimum(d->Minimum);
  404. this->setMaximum(d->Maximum);
  405. this->setMinimumValue(_minvalue);
  406. this->setMinimumPosition(_minvalue);
  407. this->setMaximumValue(_maxvalue);
  408. this->setMaximumPosition(_maxvalue);
  409. this->blockSignals(oldBlockSignals);
  410. }
  411. // --------------------------------------------------------------------------
  412. double ctkDoubleRangeSlider::tickInterval()const
  413. {
  414. Q_D(const ctkDoubleRangeSlider);
  415. return d->minFromInt(d->Slider->tickInterval());
  416. }
  417. // --------------------------------------------------------------------------
  418. void ctkDoubleRangeSlider::setTickInterval(double newTickInterval)
  419. {
  420. Q_D(ctkDoubleRangeSlider);
  421. d->Slider->setTickInterval(d->toInt(newTickInterval));
  422. }
  423. // --------------------------------------------------------------------------
  424. bool ctkDoubleRangeSlider::hasTracking()const
  425. {
  426. Q_D(const ctkDoubleRangeSlider);
  427. return d->Slider->hasTracking();
  428. }
  429. // --------------------------------------------------------------------------
  430. void ctkDoubleRangeSlider::setTracking(bool enable)
  431. {
  432. Q_D(ctkDoubleRangeSlider);
  433. d->Slider->setTracking(enable);
  434. }
  435. // --------------------------------------------------------------------------
  436. void ctkDoubleRangeSlider::triggerAction( QAbstractSlider::SliderAction action)
  437. {
  438. Q_D(ctkDoubleRangeSlider);
  439. d->Slider->triggerAction(action);
  440. }
  441. // --------------------------------------------------------------------------
  442. void ctkDoubleRangeSlider::setOrientation(Qt::Orientation newOrientation)
  443. {
  444. Q_D(ctkDoubleRangeSlider);
  445. if (this->orientation() == newOrientation)
  446. {
  447. return;
  448. }
  449. if (!testAttribute(Qt::WA_WState_OwnSizePolicy))
  450. {
  451. QSizePolicy sp = this->sizePolicy();
  452. sp.transpose();
  453. this->setSizePolicy(sp);
  454. this->setAttribute(Qt::WA_WState_OwnSizePolicy, false);
  455. }
  456. // d->Slider will take care of calling updateGeometry
  457. d->Slider->setOrientation(newOrientation);
  458. }
  459. // --------------------------------------------------------------------------
  460. Qt::Orientation ctkDoubleRangeSlider::orientation()const
  461. {
  462. Q_D(const ctkDoubleRangeSlider);
  463. return d->Slider->orientation();
  464. }
  465. // --------------------------------------------------------------------------
  466. bool ctkDoubleRangeSlider::symmetricMoves()const
  467. {
  468. Q_D(const ctkDoubleRangeSlider);
  469. return d->Slider->symmetricMoves();
  470. }
  471. // --------------------------------------------------------------------------
  472. void ctkDoubleRangeSlider::setSymmetricMoves(bool symmetry)
  473. {
  474. Q_D(ctkDoubleRangeSlider);
  475. d->Slider->setSymmetricMoves(symmetry);
  476. }
  477. // --------------------------------------------------------------------------
  478. void ctkDoubleRangeSlider::onValuesChanged(int newMinValue, int newMaxValue)
  479. {
  480. Q_D(ctkDoubleRangeSlider);
  481. double doubleNewMinValue = d->minFromInt(newMinValue);
  482. double doubleNewMaxValue = d->maxFromInt(newMaxValue);
  483. bool emitMinValueChanged = (d->MinValue != doubleNewMinValue);
  484. bool emitMaxValueChanged = (d->MaxValue != doubleNewMaxValue);
  485. if (!emitMinValueChanged && !emitMaxValueChanged)
  486. {
  487. return;
  488. }
  489. d->MinValue = doubleNewMinValue;
  490. d->MaxValue = doubleNewMaxValue;
  491. emit this->valuesChanged(d->MinValue, d->MaxValue);
  492. if (emitMinValueChanged)
  493. {
  494. emit this->minimumValueChanged(d->MinValue);
  495. }
  496. if (emitMaxValueChanged)
  497. {
  498. emit this->maximumValueChanged(d->MaxValue);
  499. }
  500. }
  501. // --------------------------------------------------------------------------
  502. void ctkDoubleRangeSlider::onMinPosChanged(int newPosition)
  503. {
  504. Q_D(const ctkDoubleRangeSlider);
  505. emit this->minimumPositionChanged(d->minFromInt(newPosition));
  506. }
  507. // --------------------------------------------------------------------------
  508. void ctkDoubleRangeSlider::onMaxPosChanged(int newPosition)
  509. {
  510. Q_D(const ctkDoubleRangeSlider);
  511. emit this->maximumPositionChanged(d->maxFromInt(newPosition));
  512. }
  513. // --------------------------------------------------------------------------
  514. void ctkDoubleRangeSlider::onPositionsChanged(int min, int max)
  515. {
  516. Q_D(const ctkDoubleRangeSlider);
  517. emit this->positionsChanged(d->minFromInt(min), d->maxFromInt(max));
  518. }
  519. // --------------------------------------------------------------------------
  520. void ctkDoubleRangeSlider::onRangeChanged(int min, int max)
  521. {
  522. Q_D(const ctkDoubleRangeSlider);
  523. if (!d->SettingRange)
  524. {
  525. this->setRange(d->minFromInt(min), d->maxFromInt(max));
  526. }
  527. }
  528. // --------------------------------------------------------------------------
  529. ctkRangeSlider* ctkDoubleRangeSlider::slider()const
  530. {
  531. Q_D(const ctkDoubleRangeSlider);
  532. return d->Slider;
  533. }
  534. // --------------------------------------------------------------------------
  535. void ctkDoubleRangeSlider::setSlider(ctkRangeSlider* slider)
  536. {
  537. Q_D(ctkDoubleRangeSlider);
  538. slider->setOrientation(d->Slider->orientation());
  539. slider->setMinimum(d->Slider->minimum());
  540. slider->setMaximum(d->Slider->maximum());
  541. slider->setValues(d->Slider->minimumValue(), d->Slider->maximumValue());
  542. slider->setSingleStep(d->Slider->singleStep());
  543. slider->setTracking(d->Slider->hasTracking());
  544. slider->setTickInterval(d->Slider->tickInterval());
  545. delete d->Slider;
  546. qobject_cast<QHBoxLayout*>(this->layout())->addWidget(slider);
  547. d->Slider = slider;
  548. d->connectSlider();
  549. }