• 14864阅读
  • 1回复

【QQ群信息】奇怪:在FORM1中 调FORM2,FORM2没有显示出来 [复制链接]

上一主题 下一主题
离线XChinux
 

只看楼主 倒序阅读 楼主  发表于: 2005-08-18
水饺 12:39:17
奇怪:在FORM1中 调FORM2,FORM2没有显示出来
#include "form2.h"

void Form1::show_select_formSlot()
{
  printf("Form1::show_select_formSlot()\n");
  Form2 f;
  hide();
  f.show();
}

XChinux 16:24:34
#include "myapp.h"
#include <QMessageBox>

MyAPP::MyAPP(void)
{
     ui.setupUi(this);
     connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(newSlot()));
}

MyAPP::~MyAPP(void)
{
}

void MyAPP::newSlot()
{
     //QMessageBox::information(this, "Alert", "Hello", QMessageBox::Ok);
     QDialog *Dlg = new QDialog(this);
     Dlg->resize(200, 200);
     Dlg->show();
     this->hide();
}

XChinux 16:24:41
#include <QtGui/QtGui>
#include "ui_myform.h"

class MyAPP :
     public QMainWindow
{
Q_OBJECT
public:
     MyAPP();
     ~MyAPP();
private:
     Ui::MainWindow ui;
public slots:
     void newSlot();
};

XChinux 16:24:46
// ex32.cpp : 定义控制台应用程序的入口点。
//

#include <QtGui/QtGui>
#include "myapp.h"

int main(int argc, char *argv[])
{
     QApplication app(argc, argv);
     MyAPP *myapp = new MyAPP();
     myapp->show();
     return app.exec();
}



水饺 16:41:22
     Dlg->show();
     this->hide();
如果我要返回this,主界面,该怎么办
XChinux 16:38:05
在Dlg里面加啊

XChinux 16:38:12
在它关闭的时候show出来

水饺 16:44:01
Dlg怎么有主界面的信息啊
XChinux 16:38:33
connect一下,在dlg关闭的时候,把主窗体show出来

XChinux 16:38:58
………………那不是看你自己的了么,一个对话框不可能就个空的吧,你真用的时候肯定是自己派生的一个DLG了

水饺 16:45:22
dlg里如何调用主窗体了,
XChinux 16:41:04
不是创建的时候有个this指针么

XChinux 16:41:16
QDialog dlg(this)

水饺 16:47:05
哦,
水饺 16:47:56
我在程序里没有定义this,
void Form1::show_select_formSlot()
{
  printf("Form1::show_select_formSlot()\n");
  Form2 f;
  hide();
  f.show();
}
XChinux 16:45:41
加上个this

XChinux 16:46:00
在Form2的构造函数里

水饺 16:56:04
如果我要直接返回在更上级FORM了,
例如form1调form2,form2调form3,
然后form3直接返回form1,那就是this->this了,是这样吗?
XChinux 16:50:58
this->parent

水饺 16:56:46
THANKS
水饺 18:03:04
form1 -> form2 ->form3
but,在form3中this->parent()->show();不行啊,this->parent()是object,object 没有show()啊
XChinux 19:37:01
做法应该是,发送信号

XChinux 19:37:11
主窗体接收到信号后,做出回应
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线running
只看该作者 1楼 发表于: 2005-08-21
可以参考qtforum.org里面的帖子,那里老外说的很全的
快速回复
限100 字节
 
上一个 下一个