This commit is contained in:
28
clickablecombobox.h
Normal file
28
clickablecombobox.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef CLICKABLECOMBOBOX_H
|
||||
#define CLICKABLECOMBOBOX_H
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QMouseEvent>
|
||||
|
||||
class ClickableComboBox : public QComboBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ClickableComboBox(QWidget *parent = nullptr) : QComboBox(parent) {}
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event) override
|
||||
{
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
emit clicked();
|
||||
}
|
||||
QComboBox::mousePressEvent(event);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CLICKABLECOMBOBOX_H
|
||||
Reference in New Issue
Block a user