1、对方框(模态对话框和非模态对话框)
void MainWindow::open()
{
QDialog *dialog = new QDialog;
dialog->setWindowTitle(tr("Hello, dialog!"));
dialog->show();
}
这样在堆上建立的对方框,如果多次点击会生成多个相同的对方框,如何保证只有一个呢???
在头文件把 定义为 QDialog dialog
void MainWindow::open()
{
dialog.setWindowTitle(tr("Hello, dialog!"));
dialog.show();
} 可以保证只有一个对话框
也可以 在头文件把 定义为 QDialog *dialog=NULL
void MainWindow::open()
{ if (dialog==NULL)
{
dialog=new QDialog;//这里不指定父窗体,存在内存泄漏
}
dialog->setWindowTitle("Hello ,dialog");
dialog->show();
}
解决办法添加 dialog->setAttribute(Qt::WA_DeleteOnClose);
2、对话框之间的数据传递,原文不详,下文中有详细讲解(实际是类的继承,和函数的覆盖)
https://blog.youkuaiyun.com/qq1113673178/article/details/108970172
3、标准对话框,如何把对话框的英文改为中文?
https://www.cnblogs.com/rogation/p/3927754.html
4、新的信号与槽的章节和旧章节的区别是成员函数添加了const 修饰
定义函数时,后面加const意义 https://blog.youkuaiyun.com/ranyongqing/article/details/25594795