C++ 入門指南 V2.00 - 單元 28 範例及練習程式碼



encryptwindow.h


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef ENCRYPTWINDOW_H
#define ENCRYPTWINDOW_H
 
#include <QMainWindow>
 
#include "encrypt.h"
 
namespace Ui {
class EncryptWindow;
}
 
class EncryptWindow : public QMainWindow
{
   Q_OBJECT
 
public:
   explicit EncryptWindow(QWidget *parent = 0);
   ~EncryptWindow();
 
private slots:
   void on_pushButton_new_clicked();
   void on_pushButton_save_clicked();
   void on_pushButton_load_clicked();
   void on_pushButton_encode_clicked();
   void on_pushButton_decode_clicked();
   void on_pushButton_clear_clicked();
   void on_pushButton_copy_clicked();
 
private:
   Ui::EncryptWindow *ui;
};
 
#endif // ENCRYPTWINDOW_H

encryptwindow.cpp


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "encryptwindow.h"
#include "ui_encryptwindow.h"
 
// 建構函數
EncryptWindow::EncryptWindow(QWidget *parent) :
   QMainWindow(parent),
   ui(new Ui::EncryptWindow)
{
   ui->setupUi(this);
}
 
// 解構函數
EncryptWindow::~EncryptWindow()
{
   delete ui;
}
 
// 按下 New 按鈕的事件
void EncryptWindow::on_pushButton_new_clicked()
{
   ui->label_display->setText("This is New button.");
}
 
// 按下 Save 按鈕的事件
void EncryptWindow::on_pushButton_save_clicked()
{
   ui->label_display->setText("This is Save button.");
}
 
// 按下 Load 按鈕的事件
void EncryptWindow::on_pushButton_load_clicked()
{
   ui->label_display->setText("This is Load button.");
}
 
// 按下 Encode 按鈕的事件
void EncryptWindow::on_pushButton_encode_clicked()
{
   ui->label_display->setText("This is Encode button.");
}
 
// 按下 Decode 按鈕的事件
void EncryptWindow::on_pushButton_decode_clicked()
{
   ui->label_display->setText("This is Decode button.");
}
 
// 按下 Clear 按鈕的事件
void EncryptWindow::on_pushButton_clear_clicked()
{
   ui->label_display->setText("This is Clear button.");
}
 
// 按下 Copy 按鈕的事件
void EncryptWindow::on_pushButton_copy_clicked()
{
   ui->label_display->setText("This is Copy button.");
}

gamewindow.h


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef GAMEWINDOW_H
#define GAMEWINDOW_H
 
#include <QMainWindow>
 
#include "guessgame.h"
 
namespace Ui {
class GameWindow;
}
 
class GameWindow : public QMainWindow
{
    Q_OBJECT
 
public:
    explicit GameWindow(QWidget *parent = 0);
    ~GameWindow();
 
private slots:
    void on_pushButton_clicked();
    void on_pushButton_2_clicked();
 
private:
    Ui::GameWindow *ui;
};
 
#endif // GAMEWINDOW_H

gamewindow.cpp


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "gamewindow.h"
#include "ui_gamewindow.h"
 
GameWindow::GameWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::GameWindow)
{
    ui->setupUi(this);
}
 
GameWindow::~GameWindow()
{
    delete ui;
}
 
void GameWindow::on_pushButton_clicked()
{
    ui->textBrowser->append("This is New Game Button.");
}
 
void GameWindow::on_pushButton_2_clicked()
{
    ui->textBrowser->append("These is Guess Button.");
}

the end

沒有留言: