假设我有一个主窗口。
当我点击一个按钮时,我想要一个子窗口打开并隐藏主窗口。 然后当我关闭那个子窗口时,我希望主窗口重新出现。
目前,我通过以下方式打开该子窗口:
s=new SignUpWindow(NULL,temp);
s->show();
这里的s是我的主窗口的一个私有指针。
当我尝试执行以下操作时:
s=new SignUpWindow(this,temp);
s->show();
窗口未显示。
以下是其头文件中构造函数的签名:
SignUpWindow (QWidget* parent=NULL, Netflix *n=NULL);
有人能解释一下为什么我们在头文件中将parent设置为NULL吗? 当我尝试调整它的参数时,有时会出现如下错误:
谢谢你们的帮助 - 一位正在学习qt的疲惫大学生candidate expects 1 argument, 2 provided qt
更新: 以下是我的主窗口头文件:
class LoginWindow : public QWidget
{
Q_OBJECT
public:
LoginWindow (QWidget* parent=NULL, Netflix *n=NULL);
public slots:
void loggedIn();
void newUser();
void quitPushed();
private:
QPushButton *quitButton, *loginButton, *newUserButton;
QLineEdit *login;//this is the text area that takes in the loginID
};
#endif
然后有一个函数是通过按钮点击启动的,它打开了一个新的窗口:
void LoginWindow::newUser()
{
s=new SignUpWindow(NULL,temp);
s->show();
//this->hide();
}
如何将 s 连接到 LogInWindow?
更新2 SignUpWIndow.h:
class SignUpWindow : public QWidget
{
Q_OBJECT
public:
SignUpWindow (QWidget* parent=NULL, Netflix *n=NULL);
public slots:
private:
};
SignUpWindow.cpp:
SignUpWindow::SignUpWindow (QWidget* parent, Netflix *n) : QWidget (parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout;
//then i add things like buttons and group boxes and etc but no dialogs...
}
我从未为我的注册窗口创建过对话框。我只是添加了布局和按钮等。