You can install a eventFilter on the combobox and react when it is a focus in event
or tell the user to press the spacebar (default behaviour for comboboxes)
.h
public:
public:
bool eventFilter(QObject *obj, QEvent *event);
To copy to clipboard, switch view to plain text mode
.cpp
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->comboBox->installEventFilter(this);
}
{
if(event
->type
() == QEvent::FocusIn) {
if(tmp->reason() == Qt::TabFocusReason || tmp->reason() == Qt::BacktabFocusReason)
{
ui->comboBox->showPopup();
}
}
return false;
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->comboBox->installEventFilter(this);
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::FocusIn)
{
QFocusEvent * tmp = static_cast<QFocusEvent *>(event);
if(tmp->reason() == Qt::TabFocusReason || tmp->reason() == Qt::BacktabFocusReason)
{
ui->comboBox->showPopup();
}
}
return false;
}
To copy to clipboard, switch view to plain text mode
Bookmarks