异度部落格

学习是一种生活态度。

0%

QT学习笔记之九 SpliterEditor

没话说...直接贴代码

splitereditor.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef SPLITEREDITOR_H
#define SPLITEREDITOR_H
#include <QtGui/QWidget>
class QSplitter;
class QTextEdit;
namespace Ui
{
class SpliterEditor;
}
class SpliterEditor : public QWidget
{
Q_OBJECT
public:
SpliterEditor(QWidget *parent = 0);
~SpliterEditor();
private:
Ui::SpliterEditor *ui;
QSplitter *splitter;
QTextEdit *editor1;
QTextEdit *editor2;
QTextEdit *editor3;
};
#endif // SPLITEREDITOR_H

splitereditor.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <QtGui>
#include "splitereditor.h"
#include "ui_splitereditor.h"
SpliterEditor::SpliterEditor(QWidget *parent)
: QWidget(parent), ui(new Ui::SpliterEditor)
{
ui->setupUi(this);
splitter = new QSplitter(Qt::Horizontal);
editor1 = new QTextEdit;
editor2 = new QTextEdit;
editor3 = new QTextEdit;
splitter->addWidget(editor1);
splitter->addWidget(editor2);
splitter->addWidget(editor3);
editor1->setPlainText("Killua");
editor2->setPlainText("KK");
editor3->setPlainText("Hello World");
splitter->show();
}
SpliterEditor::~SpliterEditor()
{
delete ui;
}