16,240
社区成员
发帖
与我相关
我的任务
分享
#ifndef DIALOG_H
#define DIALOG_H
#include <QtGui/QDialog>
#include<QKeyEvent>
#include<pageone.h>
class Dialog : public QDialog
{
Q_OBJECT
public:
Dialog(QWidget *parent = 0);
~Dialog();
private:
void keyPressEvent(QKeyEvent *event);
PageOne *page;
signals:
void del();
};
#endif // DIALOG_H
#include <QDialog>
#include<QLabel>
class PageOne : public QDialog
{
Q_OBJECT
public:
explicit PageOne(QWidget *parent = 0);
signals:
public slots:
private:
QLabel *label;
protected slots:
void ShowLabel();
};
#include "dialog.h"
#include<pageone.h>
Dialog::Dialog(QWidget *parent)
: QDialog(parent)
{ page=new PageOne(this);
connect(this,SIGNAL(del()),page,SLOT(ShowLabel()));
}
Dialog::~Dialog()
{
}
void Dialog::keyPressEvent(QKeyEvent *event)
{if(event->key()==Qt::Key_1)
emit del();
}
#include "pageone.h"
#include<QDebug>
PageOne::PageOne(QWidget *parent) :
QDialog(parent)
{label=new QLabel("the first page",this);
}
void PageOne::ShowLabel()
{ label->show();
qDebug()<<"afg";
}