【发布时间】:2016-04-29 17:58:23
【问题描述】:
我是 Qt 新手(主要使用 Objective-C),所以我可能会遇到菜鸟问题。从QDialog 窗口我尝试像这样打开QMainWindow:
this->close();
SQLWindow window;
window.receivePath(path); //Path for the .sqlite file
window.show()
QDialog 关闭并且毫秒我看到一个新窗口的一瞥,但它也关闭了。以下是QMainWindow 部分:
SQLWindow::SQLWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::SQLWindow)
{
ui->setupUi(this);
this->initialSetup();
}
SQLWindow::~SQLWindow()
{
delete ui;
}
void SQLWindow::initialSetup()
{
ui->tableView->setSortingEnabled(true);
ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
}
void SQLWindow::receivePath(QString path)
{
this->openDatabase(path);
}
void SQLWindow::openDatabase(QString path)
{
//Opening database just fine
}
【问题讨论】:
-
我希望当对话框关闭时问题出在对话框应用程序中,应用程序也是如此。此外,您的窗口是一个局部变量,当范围结束时将不再存在。