qt新手,如何从lineedit获取输入信息
伴儿 2011-03-15 09:02:05 代码比较简单,建立了一个输入对话框,我的想法是点击start以后将每个lineedit里的内容保存,大侠指点一下
#include <QtGui/QApplication>
#include <QtGui/QLineEdit>
#include <QtGui/QVBoxLayout>
#include <QtGui/QBoxLayout>
#include <QtGui/QLabel>
#include <QtGui/QWidget>
#include <QtGui/QTextBrowser>
#include <QtGui/QPushButton>
#include "dialog.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget * window = new QWidget;
QLineEdit * edit1 = new QLineEdit;
QLineEdit * edit2 = new QLineEdit;
QLineEdit * edit3 = new QLineEdit;
QLineEdit * edit4 = new QLineEdit;
QLineEdit * edit5 = new QLineEdit;
QLineEdit * edit6 = new QLineEdit;
QHBoxLayout * col_1 = new QHBoxLayout;
col_1->addWidget(new QLabel("hop "));
//col_1->addSpacing(50);
col_1->addWidget(edit1);
QHBoxLayout * col_2 = new QHBoxLayout;
col_2->addWidget(new QLabel("v "));
//col_2->addSpacing(60);
col_2->addWidget(edit2);
QHBoxLayout * col_3 = new QHBoxLayout;
col_3->addWidget(new QLabel("size "));
//col_3->addSpacing(50);
col_3->addWidget(edit3);
QHBoxLayout * col_4 = new QHBoxLayout;
col_4->addWidget(new QLabel("nkept "));
//col_4->addSpacing(20);
col_4->addWidget(edit4);
QHBoxLayout * col_5 = new QHBoxLayout;
col_5->addWidget(new QLabel("charge "));
//col_5->addSpacing(20);
col_5->addWidget(edit5);
QHBoxLayout * col_6 = new QHBoxLayout;
col_6->addWidget(new QLabel("condition"));
//col_6->addSpacing(50);
col_6->addWidget(edit6);
QVBoxLayout * row = new QVBoxLayout;
row->addLayout(col_1);
row->addLayout(col_2);
row->addLayout(col_3);
row->addLayout(col_4);
row->addLayout(col_5);
row->addLayout(col_6);
QVBoxLayout * buttons = new QVBoxLayout;
QPushButton * start = new QPushButton("start");
QPushButton * cancel = new QPushButton("cancel");
buttons->addWidget(start);
buttons->addWidget(cancel);
QHBoxLayout * cols = new QHBoxLayout;
cols->addLayout(row);
cols->addLayout(buttons);
QHBoxLayout * textbrowser = new QHBoxLayout;
QTextBrowser * outcoming = new QTextBrowser;
textbrowser->addWidget(outcoming);
QVBoxLayout * result = new QVBoxLayout;
window->setLayout(result);
result->addLayout(cols);
result->addLayout(textbrowser);
window->show();
edit1->insert("alskjdf");
return a.exec();
}