• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • kdeui
  • widgets
knuminput.h
Go to the documentation of this file.
1/* This file is part of the KDE libraries
2 * Copyright (c) 1997 Patrick Dowler <dowler@morgul.fsh.uvic.ca>
3 * Copyright (c) 2000 Dirk Mueller <mueller@kde.org>
4 * Copyright (c) 2002 Marc Mutz <mutz@kde.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 */
21
22#ifndef K_NUMINPUT_H
23#define K_NUMINPUT_H
24
25#include <kdeui_export.h>
26
27#include <QtGui/QWidget>
28#include <QtGui/QSpinBox>
29
30class QSlider;
31class QSpinBox;
32class QValidator;
33
34class KIntSpinBox;
35class KNumInputPrivate;
36class KLocalizedString;
37
43class KDEUI_EXPORT KNumInput : public QWidget
44{
45 Q_OBJECT
46 Q_PROPERTY( QString label READ label WRITE setLabel )
47public:
54 explicit KNumInput(QWidget* parent=0);
55
61#ifndef KDE_NO_DEPRECATED
62 KDE_CONSTRUCTOR_DEPRECATED KNumInput(QWidget *parent, KNumInput* below);
63#endif
64
68 ~KNumInput();
69
87 virtual void setLabel(const QString & label, Qt::Alignment a = Qt::AlignLeft | Qt::AlignTop);
88
92 QString label() const;
93
97 bool showSlider() const;
98
105 void setSteps(int minor, int major);
106
112 virtual QSize sizeHint() const;
113
114protected:
119 QSlider *slider() const;
120
126 void layout(bool deep);
127
136 virtual void doLayout() = 0;
137
138private:
139 friend class KNumInputPrivate;
140 KNumInputPrivate * const d;
141
142 Q_DISABLE_COPY(KNumInput)
143};
144
145/* ------------------------------------------------------------------------ */
146
172class KDEUI_EXPORT KIntNumInput : public KNumInput
173{
174 Q_OBJECT
175 Q_PROPERTY( int value READ value WRITE setValue NOTIFY valueChanged USER true )
176 Q_PROPERTY( int minimum READ minimum WRITE setMinimum )
177 Q_PROPERTY( int maximum READ maximum WRITE setMaximum )
178 Q_PROPERTY( int singleStep READ singleStep WRITE setSingleStep )
179 Q_PROPERTY( int referencePoint READ referencePoint WRITE setReferencePoint )
180 Q_PROPERTY( double relativeValue READ relativeValue WRITE setRelativeValue )
181 Q_PROPERTY( QString suffix READ suffix WRITE setSuffix )
182 Q_PROPERTY( QString prefix READ prefix WRITE setPrefix )
183 Q_PROPERTY( QString specialValueText READ specialValueText WRITE setSpecialValueText )
184 Q_PROPERTY( bool sliderEnabled READ showSlider WRITE setSliderEnabled )
185
186public:
191 explicit KIntNumInput(QWidget *parent=0);
203 explicit KIntNumInput(int value, QWidget *parent=0,int base = 10);
204
223#ifndef KDE_NO_DEPRECATED
224 KDE_CONSTRUCTOR_DEPRECATED KIntNumInput(KNumInput* below, int value, QWidget *parent, int base = 10);
225#endif
226
232 virtual ~KIntNumInput();
233
237 int value() const;
238
242 double relativeValue() const;
243
247 int referencePoint() const;
248
253 QString suffix() const;
258 QString prefix() const;
263 QString specialValueText() const;
264
273 void setRange(int min, int max, int singleStep=1);
274
278#ifndef KDE_NO_DEPRECATED
279 KDE_DEPRECATED void setRange(int min, int max, int singleStep, bool slider);
280#endif
281
286 void setSliderEnabled(bool enabled=true);
287
291 void setMinimum(int min);
295 int minimum() const;
299 void setMaximum(int max);
303 int maximum() const;
304
308 int singleStep() const;
309
313 void setSingleStep(int step);
314
321 void setSpecialValueText(const QString& text);
322
323 virtual void setLabel(const QString & label, Qt::Alignment a = Qt::AlignLeft | Qt::AlignTop);
324
332 virtual QSize minimumSizeHint() const;
333
334public Q_SLOTS:
338 void setValue(int);
339
343 void setRelativeValue(double);
344
348 void setReferencePoint(int);
349
359 void setSuffix(const QString &suffix);
360
367 void setSuffix(const KLocalizedString &suffix);
368
376 void setPrefix(const QString &prefix);
377
382 void setEditFocus( bool mark = true );
383
384Q_SIGNALS:
389 void valueChanged(int);
390
395 void relativeValueChanged(double);
396
397private Q_SLOTS:
398 void spinValueChanged(int);
399 void slotEmitRelativeValueChanged(int);
400
401protected:
406 QSpinBox *spinBox() const;
407
408 virtual void doLayout();
409 void resizeEvent ( QResizeEvent * );
410
411private:
412 void init(int value, int _base);
413
414private:
415 class KIntNumInputPrivate;
416 friend class KIntNumInputPrivate;
417 KIntNumInputPrivate * const d;
418
419 Q_DISABLE_COPY(KIntNumInput)
420};
421
422
423/* ------------------------------------------------------------------------ */
424
425class KDoubleLine;
426
450class KDEUI_EXPORT KDoubleNumInput : public KNumInput
451{
452 Q_OBJECT
453 Q_PROPERTY( double value READ value WRITE setValue NOTIFY valueChanged USER true )
454 Q_PROPERTY( double minimum READ minimum WRITE setMinimum )
455 Q_PROPERTY( double maximum READ maximum WRITE setMaximum )
456 Q_PROPERTY( double singleStep READ singleStep WRITE setSingleStep )
457 Q_PROPERTY( QString suffix READ suffix WRITE setSuffix )
458 Q_PROPERTY( QString prefix READ prefix WRITE setPrefix )
459 Q_PROPERTY( QString specialValueText READ specialValueText WRITE setSpecialValueText )
460 Q_PROPERTY( int decimals READ decimals WRITE setDecimals )
461 Q_PROPERTY( double referencePoint READ referencePoint WRITE setReferencePoint )
462 Q_PROPERTY( double relativeValue READ relativeValue WRITE setRelativeValue )
463 Q_PROPERTY( bool sliderEnabled READ showSlider WRITE setSliderEnabled )
464 Q_PROPERTY( double exponentRatio READ exponentRatio WRITE setExponentRatio )
465
466public:
471 explicit KDoubleNumInput(QWidget *parent = 0);
472
483 KDoubleNumInput(double lower, double upper, double value, QWidget *parent=0,double singleStep=0.01,
484 int precision=2);
485
489 virtual ~KDoubleNumInput();
490
491
513#ifndef KDE_NO_DEPRECATED
514 KDE_CONSTRUCTOR_DEPRECATED KDoubleNumInput(KNumInput* below,
515 double lower, double upper, double value, QWidget *parent=0,double singleStep=0.02,
516 int precision=2);
517#endif
518
522 double value() const;
523
528 QString suffix() const;
529
534 QString prefix() const;
535
540 int decimals() const;
541
546 QString specialValueText() const;
547
554 void setRange(double min, double max, double singleStep=1, bool slider=true);
555
560 void setSliderEnabled(bool enabled);
561
565 void setMinimum(double min);
569 double minimum() const;
573 void setMaximum(double max);
577 double maximum() const;
578
582 double singleStep() const;
583
587 void setSingleStep(double singleStep);
588
592 void setDecimals(int decimals);
593
594#ifndef KDE_NO_DEPRECATED
595 KDE_DEPRECATED void setPrecision(int precision) { setDecimals(precision); }
596#endif
597
601 double referencePoint() const;
602
606 double relativeValue() const;
607
614 void setSpecialValueText(const QString& text);
615
616 virtual void setLabel(const QString & label, Qt::Alignment a = Qt::AlignLeft | Qt::AlignTop);
617 virtual QSize minimumSizeHint() const;
618
623 double exponentRatio() const;
624
629 void setExponentRatio(double dbl);
630public Q_SLOTS:
634 void setValue(double);
635
639 void setRelativeValue(double);
640
646 void setReferencePoint(double ref);
647
655 void setSuffix(const QString &suffix);
656
663 void setPrefix(const QString &prefix);
664
665Q_SIGNALS:
670 void valueChanged(double);
677 void relativeValueChanged(double);
678
679private Q_SLOTS:
680 void sliderMoved(int);
681 void spinBoxChanged(double);
682 void slotEmitRelativeValueChanged(double);
683
684protected:
685 virtual void doLayout();
686 void resizeEvent ( QResizeEvent * );
687
688 friend class KDoubleLine;
689private:
690 void init(double value, double lower, double upper,
691 double singleStep, int precision);
692 double mapSliderToSpin(int) const;
693 void updateLegacyMembers();
694
695private:
696 class KDoubleNumInputPrivate;
697 friend class KDoubleNumInputPrivate;
698 KDoubleNumInputPrivate * const d;
699
700 Q_DISABLE_COPY(KDoubleNumInput)
701};
702
703
704/* ------------------------------------------------------------------------ */
705
717class KDEUI_EXPORT KIntSpinBox : public QSpinBox
718{
719 Q_OBJECT
720 Q_PROPERTY( int base READ base WRITE setBase )
721
722public:
723
731 explicit KIntSpinBox( QWidget *parent = 0 );
732
746 KIntSpinBox(int lower, int upper, int singleStep, int value, QWidget *parent,int base = 10);
747
751 virtual ~KIntSpinBox();
752
756 void setBase(int base);
760 int base() const;
765 void setEditFocus(bool mark);
766
773 void setSuffix(const KLocalizedString &suffix);
774
775 using QSpinBox::setSuffix;
776
777protected:
778
783 virtual QString textFromValue(int) const;
784
789 virtual int valueFromText(const QString &text) const;
790
791private:
792 class KIntSpinBoxPrivate;
793 friend class KIntSpinBoxPrivate;
794 KIntSpinBoxPrivate *const d;
795
796 Q_DISABLE_COPY(KIntSpinBox)
797 Q_PRIVATE_SLOT(d, void updateSuffix(int))
798};
799
800#endif // K_NUMINPUT_H
KDoubleNumInput
An input control for real numbers, consisting of a spinbox and a slider.
Definition: knuminput.h:451
KDoubleNumInput::relativeValueChanged
void relativeValueChanged(double)
This is an overloaded member function, provided for convenience.
KDoubleNumInput::setPrecision
void setPrecision(int precision)
Definition: knuminput.h:595
KDoubleNumInput::valueChanged
void valueChanged(double)
Emitted every time the value changes (by calling setValue() or by user interaction).
KIntNumInput
An input widget for integer numbers, consisting of a spinbox and a slider.
Definition: knuminput.h:173
KIntNumInput::relativeValueChanged
void relativeValueChanged(double)
Emitted whenever valueChanged is.
KIntNumInput::valueChanged
void valueChanged(int)
Emitted every time the value changes (by calling setValue() or by user interaction).
KIntSpinBox
A QSpinBox with support for arbitrary base numbers.
Definition: knuminput.h:718
KLocalizedString
KNumInput
You need to inherit from this class if you want to implement K*NumInput for a different variable type...
Definition: knuminput.h:44
KNumInput::doLayout
virtual void doLayout()=0
You need to overwrite this method and implement your layout calculations there.
QValidator
QWidget
kdeui_export.h
prefix
QString prefix()
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal