16,173
社区成员
发帖
与我相关
我的任务
分享
#ifndef DIALOG_H
#define DIALOG_H
#include <QWizard>
#include <QPainter>
#include <QtGui/QWidget>
#include <QFile>
#include <QTextStream>
class QCheckBox;
class QGroupBox;
class QLabel;
class QLineEdit;
class QRadioButton;
////////////////////////////////////////////////////////////////////////
class ClassWizard : public QWizard
{
Q_OBJECT
public:
ClassWizard(QWidget *parent = 0);
//void accept();
};
////////////////// ConfigPage ////////////////////////
class ClassConfigPage : public QWizardPage
{
Q_OBJECT
public:
ClassConfigPage(QWidget *parent = 0);
QLineEdit *lineEdit31; /////我要在ClassConfigShowPage里用这几个lineedit
QLineEdit *lineEdit32;
QLineEdit *lineEdit33;
QLineEdit *lineEdit34;
QLineEdit *lineEdit35;
private:
QLabel *labelconfig;
QLabel *label31;
QLabel *label32;
QLabel *label33;
QLabel *label34;
QLabel *label35;
QPushButton *OKButton;
private slots:
// void savedata();
void on_OKButton_clicked();
friend class ClassConfigShowPage;
};
///////////////// ConfigShowPage ////////////////////
class ClassConfigShowPage : public QWizardPage
{
Q_OBJECT
public:
ClassConfigShowPage(QWidget *parent = 0);
private:
QLabel *labelshow;
QLabel *config;
QLabel *labelshow1;
friend class ClassConfigPage;
};
#endif // DIALOG_H
//dialog.cpp
#include "dialog.h"
#include "ui_dialog.h"
#include <QtGui>
#include <QTextStream>
ClassWizard::ClassWizard(QWidget *parent)
: QWizard(parent)
{
addPage(new IntroPage);
addPage(new ClassInfoPage);
addPage(new ClassConfigPage);
addPage(new ClassConfigShowPage);
addPage(new ClassThroughputPage);
//setPixmap(QWizard::BannerPixmap, QPixmap(":/images/banner.jpg"));
// setPixmap(QWizard::BackgroundPixmap, QPixmap(":/images/background.jpg"));
setWindowTitle(tr("Class Wizard"));
}
ClassConfigPage::ClassConfigPage(QWidget *parent)
: QWizardPage(parent)
{
setTitle(tr("ConfigPage"));
// setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/background.jpg"));
labelconfig = new QLabel("ConfigPage");
labelconfig->setWordWrap(true);
label31 = new QLabel("UE Style(central;middle;edge):");
lineEdit31 = new QLineEdit;
label31->setBuddy(lineEdit31);
QHBoxLayout *layout31 = new QHBoxLayout;
layout31->addWidget(label31);
layout31->addWidget(lineEdit31);
label32 = new QLabel("Number of BS:");
lineEdit32 = new QLineEdit;
label32->setBuddy(lineEdit32);
QHBoxLayout *layout32 = new QHBoxLayout;
layout32->addWidget(label32);
layout32->addWidget(lineEdit32);
label33 = new QLabel("Number of UE:");
lineEdit33 = new QLineEdit;
label33->setBuddy(lineEdit33);
QHBoxLayout *layout33 = new QHBoxLayout;
layout33->addWidget(label33);
layout33->addWidget(lineEdit33);
label34 = new QLabel("...:");
lineEdit34 = new QLineEdit;
label34->setBuddy(lineEdit34);
QHBoxLayout *layout34 = new QHBoxLayout;
layout34->addWidget(label34);
layout34->addWidget(lineEdit34);
label35 = new QLabel("...:");
lineEdit35 = new QLineEdit;
label35->setBuddy(lineEdit35);
QHBoxLayout *layout35 = new QHBoxLayout;
layout35->addWidget(label35);
layout35->addWidget(lineEdit35);
/////////////////////////////////////////////////////////////////
QPushButton *OKButton = new QPushButton("OK");
QVBoxLayout *leftlayout = new QVBoxLayout;
leftlayout->addLayout(layout31);
leftlayout->addLayout(layout32);
leftlayout->addLayout(layout33);
leftlayout->addLayout(layout34);
leftlayout->addLayout(layout35);
QHBoxLayout *downlayout = new QHBoxLayout;
downlayout->addLayout(leftlayout);
downlayout->addWidget(OKButton);
QVBoxLayout *layout3 = new QVBoxLayout;
layout3->addWidget(labelconfig);
layout3->addLayout(downlayout);
setLayout(layout3);
QObject::connect(OKButton, SIGNAL(clicked()), this, SLOT(on_OKButton_clicked()));
}
void ClassConfigPage::on_OKButton_clicked()
{
QFile file("F:/QtWorkshop/test_next3/123.txt");
file.open(QIODevice::ReadWrite|QIODevice::Text);
QTextStream in1(&file);
//in1 << "sdkfjioweu" <<endl;
in1 << "UE Style(central;middle;edge):" << lineEdit31->text() << endl;
QTextStream in2(&file);
in2 << "Number of BS:" << lineEdit32->text() << endl;
QTextStream in3(&file);
in3 << "Number of UE:" << lineEdit33->text() << endl;
QTextStream in4(&file);
in4 << "..." << lineEdit34->text() << endl;
QTextStream in5(&file);
in5 << "..." << lineEdit35->text() << endl;
}
ClassConfigShowPage::ClassConfigShowPage(QWidget *parent)
: QWizardPage(parent)
{
setTitle(tr("ConfigShowPage"));
// setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/background.jpg"));
labelshow = new QLabel(tr("ConfigShowPage"));
labelshow->setWordWrap(true);
QFile file("F:/QtWorkshop/test_next3/123.txt");
file.open(QIODevice::ReadOnly);
QTextStream fs(&file);
QString filecontent=fs.readAll();
config = new QLabel(filecontent);
config->setText(filecontent);
labelshow1 = new QLabel(lineEdit31->text()); //问题在这里~~
QVBoxLayout *layout4 = new QVBoxLayout;
layout4->addWidget(labelshow);
layout4->addWidget(config);
layout4->addWidget(labelshow1);
setLayout(layout4);
}