如何从QDialog传递数据? [英] How to pass data from a QDialog?

查看:115
本文介绍了如何从QDialog传递数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Qt中,在需要传递比布尔值或整数返回码更复杂的情况下,将数据从QDialog子类传递到启动对话框的组件的最优雅的方法是什么?

In Qt, what is the most elegant way to pass data from a QDialog subclass to the component that started the dialog in the cases where you need to pass down something more complex than a boolean or an integer return code?

我想从 accept()槽发出一个自定义信号,但有其他的东西吗?

I'm thinking emit a custom signal from the accept() slot but is there something else?

推荐答案

b $ b

MyQDialog dialog(this);
dialog.setFoo("blah blah blah");
if(dialog.exec() == QDialog::Accepted){
  // You can access everything you need in dialog object
  QString bar = dialog.getFoo();
}

这篇关于如何从QDialog传递数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆