ctkDoubleRangeSlider.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  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(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed,
  77. QSizePolicy::Slider));
  78. this->connectSlider();
  79. }
  80. // --------------------------------------------------------------------------
  81. void ctkDoubleRangeSliderPrivate::connectSlider()
  82. {
  83. Q_Q(ctkDoubleRangeSlider);
  84. q->connect(this->Slider, SIGNAL(minimumValueChanged(int)),
  85. q, SLOT(onMinValueChanged(int)));
  86. q->connect(this->Slider, SIGNAL(maximumValueChanged(int)),
  87. q, SLOT(onMaxValueChanged(int)));
  88. q->connect(this->Slider, SIGNAL(valuesChanged(int,int)),
  89. q, SLOT(onValuesChanged(int,int)));
  90. q->connect(this->Slider, SIGNAL(minimumPositionChanged(int)),
  91. q, SLOT(onMinPosChanged(int)));
  92. q->connect(this->Slider, SIGNAL(maximumPositionChanged(int)),
  93. q, SLOT(onMaxPosChanged(int)));
  94. q->connect(this->Slider, SIGNAL(positionsChanged(int,int)),
  95. q, SLOT(onPositionsChanged(int,int)));
  96. q->connect(this->Slider, SIGNAL(sliderPressed()),
  97. q, SIGNAL(sliderPressed()));
  98. q->connect(this->Slider, SIGNAL(sliderReleased()),
  99. q, SIGNAL(sliderReleased()));
  100. q->connect(this->Slider, SIGNAL(rangeChanged(int, int)),
  101. q, SLOT(onRangeChanged(int, int)));
  102. }
  103. // --------------------------------------------------------------------------
  104. int ctkDoubleRangeSliderPrivate::toInt(double doubleValue)const
  105. {
  106. double tmp = doubleValue / this->SingleStep;
  107. int intValue = qRound(tmp);
  108. return intValue;
  109. }
  110. // --------------------------------------------------------------------------
  111. double ctkDoubleRangeSliderPrivate::minFromInt(int intValue)const
  112. {
  113. double doubleValue = this->SingleStep * (this->MinOffset + intValue) ;
  114. return doubleValue;
  115. }
  116. // --------------------------------------------------------------------------
  117. double ctkDoubleRangeSliderPrivate::maxFromInt(int intValue)const
  118. {
  119. double doubleValue = this->SingleStep * (this->MaxOffset + intValue) ;
  120. return doubleValue;
  121. }
  122. // --------------------------------------------------------------------------
  123. void ctkDoubleRangeSliderPrivate::updateMinOffset(double value)
  124. {
  125. this->MinOffset = (value / this->SingleStep) - this->toInt(value);
  126. }
  127. // --------------------------------------------------------------------------
  128. void ctkDoubleRangeSliderPrivate::updateMaxOffset(double value)
  129. {
  130. this->MaxOffset = (value / this->SingleStep) - this->toInt(value);
  131. }
  132. // --------------------------------------------------------------------------
  133. ctkDoubleRangeSlider::ctkDoubleRangeSlider(QWidget* _parent) : Superclass(_parent)
  134. , d_ptr(new ctkDoubleRangeSliderPrivate(*this))
  135. {
  136. Q_D(ctkDoubleRangeSlider);
  137. d->init();
  138. }
  139. // --------------------------------------------------------------------------
  140. ctkDoubleRangeSlider::ctkDoubleRangeSlider(Qt::Orientation _orientation, QWidget* _parent)
  141. : Superclass(_parent)
  142. , d_ptr(new ctkDoubleRangeSliderPrivate(*this))
  143. {
  144. Q_D(ctkDoubleRangeSlider);
  145. d->init();
  146. this->setOrientation(_orientation);
  147. }
  148. // --------------------------------------------------------------------------
  149. ctkDoubleRangeSlider::~ctkDoubleRangeSlider()
  150. {
  151. }
  152. // --------------------------------------------------------------------------
  153. void ctkDoubleRangeSlider::setMinimum(double min)
  154. {
  155. Q_D(ctkDoubleRangeSlider);
  156. d->Minimum = min;
  157. if (d->Minimum >= d->MinValue)
  158. {// TBD: use same offset
  159. d->updateMinOffset(d->Minimum);
  160. }
  161. if (d->Minimum >= d->MaxValue)
  162. {// TBD: use same offset
  163. d->updateMaxOffset(d->Minimum);
  164. }
  165. d->SettingRange = true;
  166. d->Slider->setMinimum(d->toInt(min));
  167. d->SettingRange = false;
  168. emit this->rangeChanged(d->Minimum, d->Maximum);
  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. d->Maximum = max;
  181. if (d->Maximum <= d->MinValue)
  182. {// TBD: use same offset
  183. d->updateMinOffset(d->Maximum);
  184. }
  185. if (d->Maximum <= d->MaxValue)
  186. {// TBD: use same offset ?
  187. d->updateMaxOffset(d->Maximum);
  188. }
  189. d->SettingRange = true;
  190. d->Slider->setMaximum(d->toInt(max));
  191. d->SettingRange = false;
  192. emit this->rangeChanged(d->Minimum, d->Maximum);
  193. }
  194. // --------------------------------------------------------------------------
  195. double ctkDoubleRangeSlider::maximum()const
  196. {
  197. Q_D(const ctkDoubleRangeSlider);
  198. return d->Maximum;
  199. }
  200. // --------------------------------------------------------------------------
  201. void ctkDoubleRangeSlider::setRange(double min, double max)
  202. {
  203. Q_D(ctkDoubleRangeSlider);
  204. d->Minimum = min;
  205. d->Maximum = max;
  206. if (d->Minimum >= d->MinValue)
  207. {// TBD: use same offset
  208. d->updateMinOffset(d->Minimum);
  209. }
  210. if (d->Minimum >= d->MaxValue)
  211. {// TBD: use same offset
  212. d->updateMaxOffset(d->Minimum);
  213. }
  214. if (d->Maximum <= d->MinValue)
  215. {// TBD: use same offset
  216. d->updateMinOffset(d->Maximum);
  217. }
  218. if (d->Maximum <= d->MaxValue)
  219. {// TBD: use same offset ?
  220. d->updateMaxOffset(d->Maximum);
  221. }
  222. d->SettingRange = true;
  223. d->Slider->setRange(d->toInt(min), d->toInt(max));
  224. d->SettingRange = false;
  225. emit this->rangeChanged(d->Minimum, d->Maximum);
  226. }
  227. // --------------------------------------------------------------------------
  228. double ctkDoubleRangeSlider::minimumPosition()const
  229. {
  230. Q_D(const ctkDoubleRangeSlider);
  231. return d->minFromInt(d->Slider->minimumPosition());
  232. }
  233. // --------------------------------------------------------------------------
  234. void ctkDoubleRangeSlider::setMinimumPosition(double minPos)
  235. {
  236. Q_D(ctkDoubleRangeSlider);
  237. d->Slider->setMinimumPosition(d->toInt(minPos));
  238. }
  239. // --------------------------------------------------------------------------
  240. double ctkDoubleRangeSlider::maximumPosition()const
  241. {
  242. Q_D(const ctkDoubleRangeSlider);
  243. return d->maxFromInt(d->Slider->maximumPosition());
  244. }
  245. // --------------------------------------------------------------------------
  246. void ctkDoubleRangeSlider::setMaximumPosition(double maxPos)
  247. {
  248. Q_D(ctkDoubleRangeSlider);
  249. d->Slider->setMaximumPosition(d->toInt(maxPos));
  250. }
  251. // --------------------------------------------------------------------------
  252. void ctkDoubleRangeSlider::setPositions(double minPos, double maxPos)
  253. {
  254. Q_D(ctkDoubleRangeSlider);
  255. d->Slider->setPositions(d->toInt(minPos), d->toInt(maxPos));
  256. }
  257. // --------------------------------------------------------------------------
  258. double ctkDoubleRangeSlider::minimumValue()const
  259. {
  260. Q_D(const ctkDoubleRangeSlider);
  261. return d->MinValue;
  262. }
  263. // --------------------------------------------------------------------------
  264. void ctkDoubleRangeSlider::setMinimumValue(double newMinValue)
  265. {
  266. Q_D(ctkDoubleRangeSlider);
  267. newMinValue = qBound(d->Minimum, newMinValue, d->Maximum);
  268. d->updateMinOffset(newMinValue);
  269. if (newMinValue >= d->MaxValue)
  270. {
  271. d->updateMaxOffset(newMinValue);
  272. }
  273. int newIntValue = d->toInt(newMinValue);
  274. if (newIntValue != d->Slider->minimumValue())
  275. {
  276. // d->Slider will emit a minimumValueChanged signal that is connected to
  277. // ctkDoubleSlider::onValueChanged
  278. d->Slider->setMinimumValue(newIntValue);
  279. }
  280. else
  281. {
  282. double oldValue = d->MinValue;
  283. d->MinValue = newMinValue;
  284. // don't emit a valuechanged signal if the new value is quite
  285. // similar to the old value.
  286. if (qAbs(newMinValue - oldValue) > (d->SingleStep * 0.000000001))
  287. {
  288. emit this->valuesChanged(newMinValue, this->maximumValue());
  289. emit this->minimumValueChanged(newMinValue);
  290. }
  291. }
  292. }
  293. // --------------------------------------------------------------------------
  294. double ctkDoubleRangeSlider::maximumValue()const
  295. {
  296. Q_D(const ctkDoubleRangeSlider);
  297. return d->MaxValue;
  298. }
  299. // --------------------------------------------------------------------------
  300. void ctkDoubleRangeSlider::setMaximumValue(double newMaxValue)
  301. {
  302. Q_D(ctkDoubleRangeSlider);
  303. newMaxValue = qBound(d->Minimum, newMaxValue, d->Maximum);
  304. d->updateMaxOffset(newMaxValue);
  305. if (newMaxValue <= d->MinValue)
  306. {
  307. d->updateMinOffset(newMaxValue);
  308. }
  309. int newIntValue = d->toInt(newMaxValue);
  310. if (newIntValue != d->Slider->maximumValue())
  311. {
  312. // d->Slider will emit a maximumValueChanged signal that is connected to
  313. // ctkDoubleSlider::onValueChanged
  314. d->Slider->setMaximumValue(newIntValue);
  315. }
  316. else
  317. {
  318. double oldValue = d->MaxValue;
  319. d->MaxValue = newMaxValue;
  320. // don't emit a valuechanged signal if the new value is quite
  321. // similar to the old value.
  322. if (qAbs(newMaxValue - oldValue) > (d->SingleStep * 0.000000001))
  323. {
  324. emit this->valuesChanged(this->minimumValue(), newMaxValue);
  325. emit this->maximumValueChanged(newMaxValue);
  326. }
  327. }
  328. }
  329. // --------------------------------------------------------------------------
  330. void ctkDoubleRangeSlider::setValues(double newMinVal, double newMaxVal)
  331. {
  332. Q_D(ctkDoubleRangeSlider);
  333. // We can't call setMinimumValue() and setMaximumValue() as they would
  334. // generate an inconsistent state. when minimumValueChanged() is fired the
  335. // new max value wouldn't be updated yet.
  336. double newMinValue = qBound(d->Minimum, qMin(newMinVal, newMaxVal), d->Maximum);
  337. double newMaxValue = qBound(d->Minimum, qMax(newMinVal, newMaxVal), d->Maximum);
  338. d->updateMinOffset(newMinValue);
  339. d->updateMaxOffset(newMaxValue);
  340. int newMinIntValue = d->toInt(newMinValue);
  341. int newMaxIntValue = d->toInt(newMaxValue);
  342. if (newMinIntValue != d->Slider->minimumValue() ||
  343. newMaxIntValue != d->Slider->maximumValue())
  344. {
  345. // d->Slider will emit a maximumValueChanged signal that is connected to
  346. // ctkDoubleSlider::onValueChanged
  347. d->Slider->setValues(newMinIntValue, newMaxIntValue);
  348. }
  349. else
  350. {
  351. double oldMinValue = d->MinValue;
  352. double oldMaxValue = d->MaxValue;
  353. d->MinValue = newMinValue;
  354. d->MaxValue = newMaxValue;
  355. // don't emit a valuechanged signal if the new value is quite
  356. // similar to the old value.
  357. bool minChanged = qAbs(newMinValue - oldMinValue) > (d->SingleStep * 0.000000001);
  358. bool maxChanged = qAbs(newMaxValue - oldMaxValue) > (d->SingleStep * 0.000000001);
  359. if (minChanged || maxChanged)
  360. {
  361. emit this->valuesChanged(newMinValue, newMaxValue);
  362. if (minChanged)
  363. {
  364. emit this->minimumValueChanged(newMinValue);
  365. }
  366. if (maxChanged)
  367. {
  368. emit this->maximumValueChanged(newMaxValue);
  369. }
  370. }
  371. }
  372. }
  373. // --------------------------------------------------------------------------
  374. double ctkDoubleRangeSlider::singleStep()const
  375. {
  376. Q_D(const ctkDoubleRangeSlider);
  377. return d->SingleStep;
  378. }
  379. // --------------------------------------------------------------------------
  380. void ctkDoubleRangeSlider::setSingleStep(double newStep)
  381. {
  382. Q_D(ctkDoubleRangeSlider);
  383. d->SingleStep = newStep;
  384. // The following can fire A LOT of signals that shouldn't be
  385. // fired.
  386. bool oldBlockSignals = this->blockSignals(true);
  387. d->updateMinOffset(d->MinValue);
  388. d->updateMaxOffset(d->MaxValue);
  389. // update the new values of the ctkRangeSlider
  390. double _minvalue = d->MinValue;
  391. double _maxvalue = d->MaxValue;
  392. // calling setMinimum or setMaximum can change the values MinimumValue
  393. // and MaximumValue, this is why we re-set them later.
  394. this->setMinimum(d->Minimum);
  395. this->setMaximum(d->Maximum);
  396. this->setMinimumValue(_minvalue);
  397. this->setMinimumPosition(_minvalue);
  398. this->setMaximumValue(_maxvalue);
  399. this->setMaximumPosition(_maxvalue);
  400. this->blockSignals(oldBlockSignals);
  401. }
  402. // --------------------------------------------------------------------------
  403. double ctkDoubleRangeSlider::tickInterval()const
  404. {
  405. Q_D(const ctkDoubleRangeSlider);
  406. return d->minFromInt(d->Slider->tickInterval());
  407. }
  408. // --------------------------------------------------------------------------
  409. void ctkDoubleRangeSlider::setTickInterval(double newTickInterval)
  410. {
  411. Q_D(ctkDoubleRangeSlider);
  412. d->Slider->setTickInterval(d->toInt(newTickInterval));
  413. }
  414. // --------------------------------------------------------------------------
  415. bool ctkDoubleRangeSlider::hasTracking()const
  416. {
  417. Q_D(const ctkDoubleRangeSlider);
  418. return d->Slider->hasTracking();
  419. }
  420. // --------------------------------------------------------------------------
  421. void ctkDoubleRangeSlider::setTracking(bool enable)
  422. {
  423. Q_D(ctkDoubleRangeSlider);
  424. d->Slider->setTracking(enable);
  425. }
  426. // --------------------------------------------------------------------------
  427. void ctkDoubleRangeSlider::triggerAction( QAbstractSlider::SliderAction action)
  428. {
  429. Q_D(ctkDoubleRangeSlider);
  430. d->Slider->triggerAction(action);
  431. }
  432. // --------------------------------------------------------------------------
  433. void ctkDoubleRangeSlider::setOrientation(Qt::Orientation newOrientation)
  434. {
  435. Q_D(ctkDoubleRangeSlider);
  436. d->Slider->setOrientation(newOrientation);
  437. }
  438. // --------------------------------------------------------------------------
  439. Qt::Orientation ctkDoubleRangeSlider::orientation()const
  440. {
  441. Q_D(const ctkDoubleRangeSlider);
  442. return d->Slider->orientation();
  443. }
  444. // --------------------------------------------------------------------------
  445. void ctkDoubleRangeSlider::onMinValueChanged(int newValue)
  446. {
  447. Q_D(ctkDoubleRangeSlider);
  448. double doubleNewValue = d->minFromInt(newValue);
  449. if (d->MinValue == doubleNewValue)
  450. {
  451. return;
  452. }
  453. d->MinValue = doubleNewValue;
  454. emit this->valuesChanged(d->MinValue, d->MaxValue);
  455. emit this->minimumValueChanged(d->MinValue);
  456. }
  457. // --------------------------------------------------------------------------
  458. void ctkDoubleRangeSlider::onMaxValueChanged(int newValue)
  459. {
  460. Q_D(ctkDoubleRangeSlider);
  461. double doubleNewValue = d->maxFromInt(newValue);
  462. if (d->MaxValue == doubleNewValue)
  463. {
  464. return;
  465. }
  466. d->MaxValue = doubleNewValue;
  467. emit this->valuesChanged(d->MinValue, d->MaxValue);
  468. emit this->maximumValueChanged(d->MaxValue);
  469. }
  470. // --------------------------------------------------------------------------
  471. void ctkDoubleRangeSlider::onValuesChanged(int newMinValue, int newMaxValue)
  472. {
  473. Q_D(ctkDoubleRangeSlider);
  474. double doubleNewMinValue = d->minFromInt(newMinValue);
  475. double doubleNewMaxValue = d->maxFromInt(newMaxValue);
  476. bool emitMinValueChanged = (d->MinValue != doubleNewMinValue);
  477. bool emitMaxValueChanged = (d->MaxValue != doubleNewMaxValue);
  478. if (!emitMinValueChanged && !emitMaxValueChanged)
  479. {
  480. return;
  481. }
  482. d->MinValue = doubleNewMinValue;
  483. d->MaxValue = doubleNewMaxValue;
  484. emit this->valuesChanged(d->MinValue, d->MaxValue);
  485. if (emitMinValueChanged)
  486. {
  487. emit this->minimumValueChanged(d->MinValue);
  488. }
  489. if (emitMaxValueChanged)
  490. {
  491. emit this->maximumValueChanged(d->MaxValue);
  492. }
  493. }
  494. // --------------------------------------------------------------------------
  495. void ctkDoubleRangeSlider::onMinPosChanged(int newPosition)
  496. {
  497. Q_D(const ctkDoubleRangeSlider);
  498. emit this->minimumPositionChanged(d->minFromInt(newPosition));
  499. }
  500. // --------------------------------------------------------------------------
  501. void ctkDoubleRangeSlider::onMaxPosChanged(int newPosition)
  502. {
  503. Q_D(const ctkDoubleRangeSlider);
  504. emit this->maximumPositionChanged(d->maxFromInt(newPosition));
  505. }
  506. // --------------------------------------------------------------------------
  507. void ctkDoubleRangeSlider::onPositionsChanged(int min, int max)
  508. {
  509. Q_D(const ctkDoubleRangeSlider);
  510. emit this->positionsChanged(d->minFromInt(min), d->maxFromInt(max));
  511. }
  512. // --------------------------------------------------------------------------
  513. void ctkDoubleRangeSlider::onRangeChanged(int min, int max)
  514. {
  515. Q_D(const ctkDoubleRangeSlider);
  516. if (!d->SettingRange)
  517. {
  518. this->setRange(d->minFromInt(min), d->maxFromInt(max));
  519. }
  520. }
  521. // --------------------------------------------------------------------------
  522. ctkRangeSlider* ctkDoubleRangeSlider::slider()const
  523. {
  524. Q_D(const ctkDoubleRangeSlider);
  525. return d->Slider;
  526. }
  527. // --------------------------------------------------------------------------
  528. void ctkDoubleRangeSlider::setSlider(ctkRangeSlider* slider)
  529. {
  530. Q_D(ctkDoubleRangeSlider);
  531. slider->setOrientation(d->Slider->orientation());
  532. slider->setMinimum(d->Slider->minimum());
  533. slider->setMaximum(d->Slider->maximum());
  534. slider->setValues(d->Slider->minimumValue(), d->Slider->maximumValue());
  535. slider->setSingleStep(d->Slider->singleStep());
  536. slider->setTracking(d->Slider->hasTracking());
  537. slider->setTickInterval(d->Slider->tickInterval());
  538. delete d->Slider;
  539. qobject_cast<QHBoxLayout*>(this->layout())->addWidget(slider);
  540. d->Slider = slider;
  541. d->connectSlider();
  542. }