myCombox.h
#ifndef MYCOMBOX_H
#define MYCOMBOX_H
#include <QComboBox>
class myCombox : public QComboBox
{
Q_OBJECT
public:
myCombox(QWidget *parent = nullptr);
virtual void showPopup() override;
};
#endif // MYCOMBOX_H
myCombox.cpp
#include "myCombox.h"
#include <QDebug>
myCombox::myCombox(QWidget *parent)
: QComboBox(parent)
{
}
void myCombox::showPopup()
{
QComboBox::showPopup();
QWidget *popup = this->findChild<QFrame*>();
QPoint pos = mapToGlobal(QPoint(0,0));
popup->move(popup->x(), pos.y() + this->height());
}
提升控件
运行结果:向下展开