Qt入门

// 两个 Pushbutton (ok_one, ok_two) 这是给 radiobutton 和 checkbutton用的

QLabel *click_label; //显示在 LCD 上面的文字
QLabel *picture; //企鹅的图像
QLineEdit *LineEdit; //用来显示 radio button 的状态
QMultiLineEdit *MultiLineEdit; //用来显示 check box 的状态

QLCDNumber *LCD; // 数字显示.用来显示 radio button 和 check box 後面的 ok 被按下去的次数.

QPushButton *exit_button; // 退出程式
QPushButton *clear_button; // 清除全去选项

QButtonGroup *group_three;
QRadioButton *dec;
QRadioButton *oct;
QRadioButton *bin;
QRadioButton *hex;
QPushButton *lcd_ok_button;

// 另外的一个 ButtonGroup,包括了 RadioButton dec, oct, bin, hex 和 push button lcd_ok_button
// 这个是用来选择 LCD 的选择方式的


QString CHECK; // MultlLineEdit 在显示 check box 状态时,需要的一个 string

int i; // 我们的 LCD 用来统计数字用的

private slots:
void check_radio (); //检查 radio button 状态的 slot
void check_box (); // 检查 check box 状态的 slot
void check_lcd (); // 检查 LCD 显示状态的 slot
void CLEAR (); // 清除任何选择,回覆到程式开始原状的 slot
};

#endif // 结束了


//final.cpp
#include "final.h"

#include // exit_button 需要用到 quit 来退出 kapplication
#include // buttongroup 用到
#include // checkbox 用到
#include &l;qgroupbox.h> // groupbox 用到
#include // label 用到
#include // LCD 用到
#include // lineedit 用到
#include // multilineedit 用到
#include // pushbutton 用到
#include // radiobutton 用到
#include // LCD 用到
#include // 图像 (企鹅) 用到
#include // multilineedit 用来显示 check_box 状态的 string 用到

Final::Final (QWidget * parent, const char *name): //主程式开始了
QDialog (parent, name)
{
if (!name)
setName ("Final");
resize (596, 480);
setCaption (tr ("Final")); //命名为 Final

i = 0; //计数器最开始的值是 0

group_one = new QButtonGroup (this, "group_one");
group_one->setGeometry (QRect (0, 0, 110, 121));
group_one->setTitle (tr ("Group"));

radio_one = new QRadioButton (group_one, "radio_one");
radio_one->setGeometry (QRect (10, 20, 90, 40));
radio_one->setText (tr ("One"));
radio_one->setChecked (TRUE);

radio_two = new QRadioButton (group_one, "radio_two");
radio_two->setGeometry (QRect (10, 70, 90, 40));
radio_two->setText (tr ("Two"));

// 设定第一个 buttongroup, 并且在 buttongroup 上面设定 radio button 1 和 radio button 2
// radio_one 的 default 是 checked (已被选择的)

group_two = new QGroupBox (this, "group_two");
group_two->setGeometry (QRect (0, 120, 111, 201));
group_two->setTitle (tr ("Group 2"));

check_one = new QCheckBox (group_two, "check_one");
check_one->setGeometry (QRect (10, 20, 90, 40));
check_one->setText (tr ("One"));
check_one->setChecked (TRUE);

check_two = new QCheckBox (group_two, "check_two");
check_two->setGeometry (QRect (10, 80, 90, 40));
check_two->setText (tr ("Two"));

check_three = new QCheckBox (group_two, "check_three");
check_three->setGeometry (QRect (10, 140, 90, 40));
check_three->setText (tr ("Three"));

// 第二个 group 我们改用 groupbox 来作范例. 并且在 group box 上面
// 生成三个 check box , check box 1, check box 2 和 check box 3
// check_one 的 default 是 checked (已被选择的)

ok_one = new QPushButton (this, "ok_one");
ok_one->setGeometry (QRect (120, 30, 71, 61));
ok_one->setText (tr ("OK"));

// 第一个 ok button, 我们用来检查 radio button 的状态

ok_two = new QPushButton (this, "ok_two");
ok_two->setGeometry (QRect (120, 190, 71, 61));
ok_two->setText (tr ("OK"));

// 第二个 ok button, 用来检查 check box 的状态

click_label = new QLabel (this, "click_label");
click_label->setGeometry (QRect (250, 270, 190, 41));
QFont click_label_font (click_label->font ());
click_label_font.setPointSize (1Cool;
click_label->setFont (click_label_font);
click_label->setText (tr ("Click On OK"));
click_label->setAlignment (int (QLabel::AlignCenter));

// 在 LCD 的数字上方显示一些字. 这里我们显示的是 Click On Ok
// 也就是说, LCD 是显示的 ok button 被 mouse clicked 过的次数.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值