Qt在第一个窗口关闭时打开另一个窗口
Qt opening another window when first one has closed
我已经对Java编程有一段时间了......现在我进入了C++和Qt,我对GUI线程(EDT线程)和工作线程有点迷茫我尝试仅在配置窗口关闭时打开应用程序的主窗口。我不想将用于创建主窗口的代码放在配置窗口的"确定"按钮中。我试图使它们成为模态,但主窗口仍然打开.....船尾配置已完成,我仍然需要查看是否有应用程序更新...所以它的东西像
编辑:这是我的主要:
ConfigurationWindow *cw = new ConfigurationWindow();
//if there is no text file - configuration
cw->show();
//**I need to stop here until user fills the configuration
MainWindow *mw = new MainWindow();
ApplicationUpdateThread *t = new ApplicationUpdateThread();
//connect app update thread with main window and starts it
mw->show();
尝试这样的事情:
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QDialog *dialog = new QDialog;
QSlider *slider = new QSlider(dialog);
QHBoxLayout *layout = new QHBoxLayout(dialog);
layout->addWidget(slider);
dialog->setLayout(layout);
dialog->exec();
qDebug() << slider->value(); // prints the slider's value when dialog is closed
QMainWindow mw; // in your version this could be MainWindow mw(slider->value());
w.show();
return a.exec();
}
这个想法是主窗口的构造函数可以接受来自QDialog的参数。在这个人为的示例中,我只是使用 qDebug() 在 QDialog 关闭时打印滑块的值,而不是将其作为参数传递,但你明白了。
编辑:您可能还希望在创建主窗口之前"删除"对话框以节省内存。在这种情况下,您需要在删除对话框之前将主窗口构造函数的参数存储为单独的变量。
你必须了解信号和插槽。基本思想是,您将在配置完成后发送信号。你把你的QMainWindow放在一个成员变量中,并在与configurationDone信号连接的主程序的一个插槽中调用mw->show()。
如果你的 ConfigurationWindow 是一个 QDialog,你可以将 finish(int) 信号连接到 MainWindow 的 show() 插槽(并省略 main 的 show() 调用)。
相关文章:
- 如何通过按下第三个窗口中的按钮,将QString从一个窗口获取到另一个窗口
- 如何将一个窗口保留在另一个应用程序窗口的前面
- Qt:从另一个窗口访问公共对象
- 触发另一个窗口的菜单按钮
- 如何在Qt中管理另一个窗口?
- 将变量从主窗口传递到另一个qt c++窗体
- Gtkmm - 关闭窗口然后显示另一个窗口的正确方法
- 当电子的窗口隐藏时如何激活另一个应用程序窗口
- 发送到另一个窗口的鼠标移动消息不执行任何操作
- xcb_get_image_reply另一个工作区/桌面上的窗口失败
- C++ 从另一个程序窗口的内存中编辑文本
- 在另一个C 程序的窗口中打开.exe
- 将窗口句柄从一个进程使用到另一个进程(插件 vst 音频)
- Win32/Gdigrab - 如何将另一个进程窗口设置为无边框
- 无法更改另一个窗口内窗口的背景颜色
- 更改如何从另一个窗口从Mainwindow接收信号
- 将文件从一个位置移至窗口C 的另一个位置
- 使用启动命令启动命令时,将命令传递到另一个 cmd 窗口
- 如何在没有窗口类的情况下编写QT系统托盘应用程序,并将其与另一个进程集成
- 具有两个窗口的C++中的应用程序.任务栏中显示的一个窗口.另一个未显示