itom
Loading...
Searching...
No Matches
comboBox.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2020, Institut für Technische Optik (ITO),
5 Universität Stuttgart, Germany
6
7 This file is part of itom and its software development toolkit (SDK).
8
9 itom is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Library General Public Licence as published by
11 the Free Software Foundation; either version 2 of the Licence, or (at
12 your option) any later version.
13
14 In addition, as a special exception, the Institut für Technische
15 Optik (ITO) gives you certain additional rights.
16 These rights are described in the ITO LGPL Exception version 1.0,
17 which can be found in the file LGPL_EXCEPTION.txt in this package.
18
19 itom is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
22 General Public Licence for more details.
23
24 You should have received a copy of the GNU Library General Public License
25 along with itom. If not, see <http://www.gnu.org/licenses/>.
26
27 This file is a port and modified version of the
28 Common framework (http://www.commontk.org)
29*********************************************************************** */
30
31#ifndef COMBOBOX_H
32#define COMBOBOX_H
33
34// Qt includes
35#include <QComboBox>
36
37// CTK includes
38//#include "ctkPimpl.h"
39#include "commonWidgets.h"
40class ComboBoxPrivate;
41
54class ITOMWIDGETS_EXPORT ComboBox : public QComboBox
55{
56 Q_OBJECT
57 Q_PROPERTY(QString defaultText READ defaultText WRITE setDefaultText)
58 Q_PROPERTY(QIcon defaultIcon READ defaultIcon WRITE setDefaultIcon)
59 Q_PROPERTY(bool forceDefault READ isDefaultForced WRITE forceDefault)
60 Q_PROPERTY(Qt::TextElideMode elideMode READ elideMode WRITE setElideMode)
64 Q_PROPERTY(ScrollEffect scrollWheelEffect READ scrollWheelEffect WRITE setScrollWheelEffect)
66 Q_PROPERTY(QString currentUserDataAsString READ currentUserDataAsString WRITE setCurrentUserDataAsString)
67
68public:
70 explicit ComboBox(QWidget* parent = 0);
71 virtual ~ComboBox();
72
74 void setDefaultText(const QString&);
75 QString defaultText()const;
76
78 void setDefaultIcon(const QIcon&);
79 QIcon defaultIcon()const;
80
83 void forceDefault(bool forceDefault);
84 bool isDefaultForced()const;
85
88 void setElideMode(const Qt::TextElideMode& newMode);
89 Qt::TextElideMode elideMode()const;
90
93 {
103 ScrollWithNoVScrollBar
104 };
105
106 //Q_ENUM exposes a meta object to the enumeration types, such that the key names for the enumeration
107 //values are always accessible.
108 Q_ENUM(ScrollEffect);
109
112 ScrollEffect scrollWheelEffect()const;
115 void setScrollWheelEffect(ScrollEffect scroll);
116
118 virtual QSize minimumSizeHint()const;
120 virtual QSize sizeHint()const;
121
123 QString currentUserDataAsString()const;
124
125public slots:
127 void setCurrentUserDataAsString(QString userData);
128
129protected:
131 virtual void paintEvent(QPaintEvent* event);
132 virtual void changeEvent(QEvent* event);
133 virtual void wheelEvent(QWheelEvent* event);
134
135protected:
136 QScopedPointer<ComboBoxPrivate> d_ptr;
137
138private:
139 Q_DECLARE_PRIVATE(ComboBox);
140 Q_DISABLE_COPY(ComboBox);
141};
142
143#endif
ComboBox is an advanced QComboBox. It adds multiple features:
Definition comboBox.h:55
ScrollEffect
\tbd turn into flags ?
Definition comboBox.h:93
@ NeverScroll
Scrolling is not possible with the mouse wheel.
Definition comboBox.h:95
@ AlwaysScroll
Scrolling is always possible with the mouse wheel.
Definition comboBox.h:97
@ ScrollWithFocus
Definition comboBox.h:100
Definition comboBox.cpp:44