【发布时间】:2017-08-22 13:34:58
【问题描述】:
我有一个带有通过设计器添加的图像的标签,我想处理它们的调整大小事件。所以我希望在调整大小后调用一个特定的函数。 我该怎么做?
【问题讨论】:
我有一个带有通过设计器添加的图像的标签,我想处理它们的调整大小事件。所以我希望在调整大小后调用一个特定的函数。 我该怎么做?
【问题讨论】:
您可以为标签安装事件过滤器。
更多细节可以查看Qt文档Event filters
例子:
MainWidget::MainWidget(QWidget* parent) : QWidget(parent)
{
ui.setupUi(this);
theLabel->installEventFilter(this);
}
bool MainWidget::eventFilter(QObject* o, QEvent* e)
{
if(e->type() == QEvent::Resize)
{
//manage the resize event
}
return false;
}
【讨论】: