JKQtExtras
a library of useful Qt widgets and tools
jkqteenhancedcombobox.h
1 #ifndef JKQTEENHANCEDCOMBOBOX_H
2 #define JKQTEENHANCEDCOMBOBOX_H
3 
4 #include <QComboBox>
5 #include "jkqtextras_imexport.h"
6 #include <QKeyEvent>
7 
8 /** \brief this QComboox descendent with en hanced features (e.g. can be set to
9  * read-only, editingFinished() signal, ...)
10  * \ingroup JKQtExtrasWidgetsEdits
11  *
12  * Added features are:
13  * - setReadonly() slot, which shows the combobox in the standardway, but prevents editing (and deletes any key-press events)
14  * - editingFinished() signal, which is emitted when "return" or "enter" key is pressed
15  * .
16  *
17  * \image html JKQTEEnhancedComboBox.png
18  *
19  * Usage example:
20  * \snippet jkqtextras_test/testmainwindow.cpp Example: JKQTEEnhancedComboBox
21  */
22 class JKQTEXTRAS_LIB_EXPORT JKQTEEnhancedComboBox : public QComboBox {
23  Q_OBJECT
24  Q_PROPERTY(bool readonly READ readonly WRITE setReadonly USER true)
25  public:
26  explicit JKQTEEnhancedComboBox(QWidget *parent = 0);
27 
28  virtual void showPopup();
29  /** \brief is the combobox in read-only mode? */
30  bool readonly() const;
31 
32 
33  public slots:
34  /** \brief switches the combobox between read-only mode and editable mode */
35  void setReadonly(bool readonly);
36 
37  signals:
38  /** \brief signal, which is emitted when the editing of the widget finishes.
39  *
40  * This signal is emitted when \c setEditbale(true) was set and the editing in the widget
41  * finished, i.e. a text is entered and RETURN or ENTER is pressed.
42  */
44 
45  protected:
46  bool m_readonly;
48  virtual void keyPressEvent ( QKeyEvent * e );
49  virtual void keyReleaseEvent ( QKeyEvent * e );
50  virtual void wheelEvent ( QWheelEvent * e );
51 };
52 
53 #endif // JKQTEENHANCEDCOMBOBOX_H
54 
JKQTEEnhancedComboBox
this QComboox descendent with en hanced features (e.g. can be set to read-only, editingFinished() sig...
Definition: jkqteenhancedcombobox.h:22
JKQTEEnhancedComboBox::m_oldEditable
bool m_oldEditable
Definition: jkqteenhancedcombobox.h:47
JKQTEEnhancedComboBox::setReadonly
void setReadonly(bool readonly)
switches the combobox between read-only mode and editable mode
JKQTEXTRAS_LIB_EXPORT
#define JKQTEXTRAS_LIB_EXPORT
Definition: jkqtextras_imexport.h:95
JKQTEEnhancedComboBox::keyReleaseEvent
virtual void keyReleaseEvent(QKeyEvent *e)
JKQTEEnhancedComboBox::editingFinished
void editingFinished()
signal, which is emitted when the editing of the widget finishes.
JKQTEEnhancedComboBox::m_readonly
bool m_readonly
Definition: jkqteenhancedcombobox.h:46
JKQTEEnhancedComboBox::wheelEvent
virtual void wheelEvent(QWheelEvent *e)
JKQTEEnhancedComboBox::keyPressEvent
virtual void keyPressEvent(QKeyEvent *e)
JKQTEEnhancedComboBox::readonly
bool readonly() const
is the combobox in read-only mode?
JKQTEEnhancedComboBox::JKQTEEnhancedComboBox
JKQTEEnhancedComboBox(QWidget *parent=0)
JKQTEEnhancedComboBox::showPopup
virtual void showPopup()