ctkDoubleRangeSlider.cpp 19 KB

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