JKQtExtras
a library of useful Qt widgets and tools
JKQTEEnhancedComboBox Class Reference

this QComboox descendent with en hanced features (e.g. can be set to read-only, editingFinished() signal, ...) More...

#include <jkqteenhancedcombobox.h>

Inheritance diagram for JKQTEEnhancedComboBox:
Collaboration diagram for JKQTEEnhancedComboBox:

Public Slots

void setReadonly (bool readonly)
 switches the combobox between read-only mode and editable mode More...
 

Signals

void editingFinished ()
 signal, which is emitted when the editing of the widget finishes. More...
 

Public Member Functions

 JKQTEEnhancedComboBox (QWidget *parent=0)
 
bool readonly () const
 is the combobox in read-only mode? More...
 
virtual void showPopup ()
 

Protected Member Functions

virtual void keyPressEvent (QKeyEvent *e)
 
virtual void keyReleaseEvent (QKeyEvent *e)
 
virtual void wheelEvent (QWheelEvent *e)
 

Protected Attributes

bool m_oldEditable
 
bool m_readonly
 

Properties

bool readonly
 

Detailed Description

this QComboox descendent with en hanced features (e.g. can be set to read-only, editingFinished() signal, ...)

Added features are:

  • setReadonly() slot, which shows the combobox in the standardway, but prevents editing (and deletes any key-press events)
  • editingFinished() signal, which is emitted when "return" or "enter" key is pressed

Usage example:

cmbReadOnly->setReadonly(true);
cmbReadOnly->setEditable(false);
cmbReadOnly->addItem("item 1");
cmbReadOnly->addItem("item 2");
cmbReadOnly->addItem("item 3");
cmbReadOnly->addItem("item 4");
cmbReadOnly->setCurrentIndex(1);
[labcmbReadOnly, cmbReadOnly]() {
labcmbReadOnly->setText(tr("editingFinished: text=%1").arg(cmbReadOnly->currentText()));
});
JKQTEEnhancedComboBox* cmbReadOnlyEditable=new JKQTEEnhancedComboBox(wid);
cmbReadOnlyEditable->setReadonly(true);
cmbReadOnlyEditable->setEditable(true);
cmbReadOnlyEditable->addItem("item 1");
cmbReadOnlyEditable->addItem("item 2");
cmbReadOnlyEditable->addItem("item 3");
cmbReadOnlyEditable->addItem("item 4");
cmbReadOnlyEditable->setCurrentIndex(1);
connect(cmbReadOnlyEditable, &JKQTEEnhancedComboBox::editingFinished,
[labcmbReadOnlyEditable, cmbReadOnlyEditable]() {
labcmbReadOnlyEditable->setText(tr("editingFinished: text=%1").arg(cmbReadOnlyEditable->currentText()));
});
cmbEditable->addItem("item 1");
cmbEditable->addItem("item 2");
cmbEditable->addItem("item 3");
cmbEditable->addItem("item 4");
cmbEditable->setCurrentIndex(1);
cmbEditable->setEditable(true);
[labcmbEditable, cmbEditable]() {
labcmbEditable->setText(tr("editingFinished: text=%1").arg(cmbEditable->currentText()));
});

Constructor & Destructor Documentation

◆ JKQTEEnhancedComboBox()

JKQTEEnhancedComboBox::JKQTEEnhancedComboBox ( QWidget *  parent = 0)
explicit

Member Function Documentation

◆ editingFinished

void JKQTEEnhancedComboBox::editingFinished ( )
signal

signal, which is emitted when the editing of the widget finishes.

This signal is emitted when setEditbale(true) was set and the editing in the widget finished, i.e. a text is entered and RETURN or ENTER is pressed.

◆ keyPressEvent()

virtual void JKQTEEnhancedComboBox::keyPressEvent ( QKeyEvent *  e)
protectedvirtual

◆ keyReleaseEvent()

virtual void JKQTEEnhancedComboBox::keyReleaseEvent ( QKeyEvent *  e)
protectedvirtual

◆ readonly()

bool JKQTEEnhancedComboBox::readonly ( ) const

is the combobox in read-only mode?

◆ setReadonly

void JKQTEEnhancedComboBox::setReadonly ( bool  readonly)
slot

switches the combobox between read-only mode and editable mode

◆ showPopup()

virtual void JKQTEEnhancedComboBox::showPopup ( )
virtual

◆ wheelEvent()

virtual void JKQTEEnhancedComboBox::wheelEvent ( QWheelEvent *  e)
protectedvirtual

Member Data Documentation

◆ m_oldEditable

bool JKQTEEnhancedComboBox::m_oldEditable
protected

◆ m_readonly

bool JKQTEEnhancedComboBox::m_readonly
protected

Property Documentation

◆ readonly

bool JKQTEEnhancedComboBox::readonly
readwrite

The documentation for this class was generated from the following file:
JKQTEEnhancedComboBox
this QComboox descendent with en hanced features (e.g. can be set to read-only, editingFinished() sig...
Definition: jkqteenhancedcombobox.h:22
JKQTEEnhancedComboBox::setReadonly
void setReadonly(bool readonly)
switches the combobox between read-only mode and editable mode
JKQTEEnhancedComboBox::editingFinished
void editingFinished()
signal, which is emitted when the editing of the widget finishes.
JKQTEEnhancedComboBox::JKQTEEnhancedComboBox
JKQTEEnhancedComboBox(QWidget *parent=0)