KanoopGuiQt 1.3.0
Qt GUI utility library
Loading...
Searching...
No Matches
combobox.h
1#ifndef COMBOBOX_H
2#define COMBOBOX_H
3
4#include <QComboBox>
5#include <Kanoop/gui/libkanoopgui.h>
6
7/**
8 * @brief QComboBox subclass with bold font helpers and keyboard-commit signals.
9 *
10 * ComboBox emits accept() when the user presses Enter/Return, and lostFocus()
11 * when the widget loses keyboard focus. Individual rows or the entire widget
12 * can have their font weight changed to bold.
13 */
14class LIBKANOOPGUI_EXPORT ComboBox : public QComboBox
15{
16 Q_OBJECT
17public:
18 /**
19 * @brief Construct with an optional parent.
20 * @param parent Optional QWidget parent
21 */
22 explicit ComboBox(QWidget *parent = nullptr);
23
24 /**
25 * @brief Set the font weight of all items in the combo box.
26 * @param bold true for bold, false for normal weight
27 */
28 void setBold(bool bold);
29
30 /**
31 * @brief Set the font weight of a specific row.
32 * @param row Zero-based row index
33 * @param bold true for bold, false for normal weight
34 */
35 void setRowBold(int row, bool bold);
36
37private:
38 virtual void keyPressEvent(QKeyEvent* event) override;
39 virtual void focusOutEvent(QFocusEvent* event) override;
40
41signals:
42 /** @brief Emitted when the user presses Enter/Return to accept the current value. */
43 void accept();
44 /** @brief Emitted when the widget loses keyboard focus. */
45 void lostFocus();
46};
47
48#endif // COMBOBOX_H
QComboBox subclass with bold font helpers and keyboard-commit signals.
Definition combobox.h:15
ComboBox(QWidget *parent=nullptr)
Construct with an optional parent.
void lostFocus()
Emitted when the widget loses keyboard focus.
void setRowBold(int row, bool bold)
Set the font weight of a specific row.
void accept()
Emitted when the user presses Enter/Return to accept the current value.
void setBold(bool bold)
Set the font weight of all items in the combo box.