MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QMetaMethod slot = metaObject()->method(
metaObject()->indexOfSlot("functChanged()"));
foreach (QWidget* w, findChildren<QWidget*>()) {
const QMetaObject *mo = w->metaObject();
if (!mo->userProperty().isValid() || !mo->userProperty().hasNotifySignal())
continue;
connect(w, mo->userProperty().notifySignal(), this, slot);
}
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::functChanged()
{
qDebug() << sender();
qDebug() << "this is a signal!!!";
}
利用Qt元对象系统获取界面上发生更改的控件代码
猜你喜欢
转载自blog.csdn.net/huoshifu/article/details/104626190
今日推荐
周排行