Tiểu luận: Tìm hiểu và sử dụng Qt để viết chương trình tạo một cửa sổ chương trình điển hình - Pdf 11



Bài 14. Tìm hiểu và sử dụng Qt để viết chương trình tạo một cửa sổ chương
trình điển hình.

 !"#$$$"#"
% !"#$#"&'(
 !" #$%&'(
)*
+,-./01234567.5.-*89,2
301:;+5.<=5>?=@A+B56,-CD:DE
3FGH,IJ*K=59+7=5LCDM/NOCC4-P565Q
%CE7LRST@.M=56:UMVNWNX8X@H5<<Q56MY
35QN7QN9C.C>CZ=5[,-<QMY37
N9C.CC4%C\*K/].C4^=+=5_56Q
]=2N`a76*[=<Q+CD5Q%N9C.C
C4@%<MY=5U-7:D>`^=+[=bN/VN
C_>5_MY=7=2IE9N/CZ-:DC_>=N/C=VNWN
C47I=*
+7H=7,-CD)ST7V56,AN7-==Dc-!7Md
%CeC-!f-QM=*T,AN75=9QM=+*
+5_56I=C=,4cgC"##hALD5D+--,C4-
=g7V=*+a767VC47,AN7=@S==:=MH@
7=NMi
QCU:A^=+7H=7:=>C
• 7MMjN,=d7C@<<Q47C?5.-!=@X0@kGM*
• <H0jH75lN*
• ma76CH7FCH7,-CD==HH7-<Q,AN756IH@
-0-IH7V=J*
• !N`nP\oo-K[=IEN/7/:V2CDI/
N`-5QG,=-MY3<*

kw=747=54C_M=-d,HC=*NN
#include "notepad.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Notepad w;
w.show();

return a.exec();
}
m=B59I=:d,HH=H7HN=GH-+{NN,=*
SB&5rx=-CC=Hoo23*
SB}47=CD5\6+{NN,=*\6-]/,~23-9%5Q
4:VI•7+-MY3+kHM*<IZ4CD5\623
=7=CM\47=7*F\23=C-IEMY3+
kH@=<QMY3+{NN,==%*J
SB€47=5\6HN=*1,-5\6C-Gw=747=,N-AN
=*=L2=%\r56?,-GHFA3J
7+*`3,-GHHH0@=D@_@-[7=*!DGHP
<Q2=GHI@CDDN4eCDY=MU23`•4*
SBhQrGHHN=7C-7CDY=MU7*GHP<
2g2=F`3CD+!=kG@75<<=E3@CH@=74
@-CD-GHIJ@<QQrCDGHV7CDY=MU7*
kH56Ce5r,-IEV‚-CMGFJ,-CGH7=*
SB$#[NICD23+5=4@MI5647=-Y5%
GH^=23*`3^=MI,-D-VN`C*
()787$!1+29  !:;2< !
kw=747=CD5rx==L75r4ƒ!X@HN=**R
[=CZd,HHN=*7+7H=7@<Mu5DCZ7+SHMH7*

<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Notepad</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>70</x>
<y>0</y>
<width>268</width>
<height>235</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTextEdit" name="textEdit"/>
</item>
<item>
<widget class="QPushButton" name="quitButton">
<property name="text">
<string>Quit</string>
</property>
</widget>
</item>
</layout>

<CCDM\I/gMCD,NooO*[~,-@,N-M,<
Q567V47jCH*P<Q7V,4=CM\^=CDM,-?<*
SB$Š5rx=CDM77<CD=CM\Ce5r56?,-N=7H*7r#
b7=7;GHIE<N=7HF<,-CDGHVN=VJ*
SB$}5rx=CDHM77/5Q/N<:D5_56MY3:Z5\
67B5L^=<*H]5e^=oo@-C^<,N
C-<56I=:@:y59:;CDV_F‹J*7+ˆ:qH@-C^/,-5Q5/C
:/7;-C^^=,N0V56?5[ICD5\6560<=E]=
CD7†5%,NMZ*
SB$'I=:CD:%-,-CD7†5%,NHN=„)*!D:%-
yCD,N3Q@-<Q%NAV/N2^=<*
C)+/,123+4-0/56/
7Hd,HC-Gw=747=,NHN=M=
#include "notepad.h"
#include "ui_notepad.h"
Notepad::Notepad(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Notepad)
{
ui->setupUi(this);
}
Notepad::~Notepad()
{
delete ui;
Œ
m=B59,Hd,HH=H7,NHN=5_5647=:ZGw=7-d,H
H=H7„)5_5647=:Z,*
SB&5rx=M77HN=-%,ANd,H„)*
SBŠ?M77+!=kG,-,NMZ,NHN=*
SB}47=CD5\6,N„)-<-*

m9%\5.IQC-<ONWNL
I†23*@7`3-[=MY3-C:/-5QC?=
,-C%-5Q<QCL-23*Q,-C5.-@[=
CCDM,I%\+:*
QI†23I[+56V@=MY3`+-%M,*
!D`56N7=ICDMI5e:0/7=-CDM,,-CD-C56?,-
5Q5N2CD`3Q*kH+5_05r7`-M,C-[=
<QMY37%Nc+SHMH7*
Y3+SHMH75QCCDM,-C@I`DN/-[+5QCZ
CD75v/-M=5<?M,z,IHFJ*
!DM,N7=H@…]K…,IHFJ@  56 C-d,HH=H7 ^=,NHN=
GH@HN=*-CD-CN7=H@HN=…]K…,IHFJ@56C-
M7Hd,H^=,NHN=GH@HN=*NN*[=b9%C_5Q-C
7M7Hd,H*
[=_-C_5_56MY=5U7H=H7d,H@HN=*
#ifndef NOTEPAD_H
#define NOTEPAD_H
#include <QMainWindow>
namespace Ui {
class Notepad;
}
class Notepad : public QMainWindow
{
Q_OBJECT

public:
explicit Notepad(QWidget *parent = 0);
~Notepad();

private slots:

CH-HCCH*R`5[N-H05QANCHf,H@HCˆNH-HC
=H*+SHMH75D47=-5D`6N*
QI%\-5D-M,@I`DN/-CD-5D-?
M,z7H7HFJ*
7L6N^=+{5647=g:/Mu0V7GHC-[
=C[-F77L6N-,-HCCHJ*%[=C\C
-5D-CD=E3@[=<Q05r:Q6[*
!_MY=5U7HN=*:1LM=
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<addaction name="actionOpen"/>
<addaction name="actionSave"/>
</widget>
<addaction name="menuFile"/>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>

QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
QString(),
tr("Text Files (*.txt);;C++ Files (*.cpp *.h)"));
if (!fileName.isEmpty()) {
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::critical(this, tr("Error"), tr("Could not
open file"));
return;
}
QTextStream in(&file);
ui->textEdit->setText(in.readAll());
file.close();
}
Œ
m-CM=HˆNHf,H=CHFJQrCDDN4N2d,H*<7/.5L
^=d,H56?@eCDa7a%L^:†DN4*
%[=<CDd,H@[=CZd,HNHFJ@7/.5[%d,H<QCZ
56*%d,HIEQCZ56@[=MY3+!HMM=HK05QQrCDDN
4CDE:,a*
5?v,MY3,N+H07H=C@C-2=:qH+f,H*m-C7H={,,FJ7/.D
^=d,HCD+7*DM=5<<Q56Qr7H0H*=5<
[=,MHFJd,H5Q7/,4d,H5.-*
K1L[=MY3-C7FJ*m-C-,-9%IC\%237.
Ev*
QMY3+f,HS=,@+f,H@+CHMM=HK0-+H07H=C@CBM=-
HN=*NN
#include <QFileDialog>
#include <QFile>
#include <QMessageBox>

[=?-5D*‘51[=?cd,H7HM7HM*
f,H7HM7HM*]75647=:Z7HN=^=GG:Z54HM=
•nSˆ’8T“z•“H7MŽ”$*#”z
•]7HM7Hz
•d,HzC=HMpNH*N•pd,Hz
•d,HzC=HMpM=H*N•pd,Hz
•p]7HM7Hz
•p“z
=,,4d,HHN=*]7-47=C3C=HM7>N9%-@Z
51,-NH-M=H*
%NH=CBM=-HN=*N75QCd,H7HM7HM-N7qH*
“Tˆ„“ToŽHN=*]7
-B,4,-?`6N=E3*
[^==E35647=-5D7{T7-IW-
=E3*S-5D<Q5654:ZCH-[7=
E3@[=<QQv=CH-=E3*
Q=M•CD-5Dv=CDCH-=E3@IW:Q6^=<c=
H7-=E3*
=E35647=*
'')F$O2!/2+08
=MuC-CDGH2=E.7*
=:y59:;CCDHC{:Z=CHˆNH-=H7>
C-5DHN=*
QI%\-5DHN=-M,@I`DN/-=HN=7{
T7-?M,z7H7HFJ*
[=CH5647=:Z+SHMH77HN=*NN@M=
void Notepad::on_actionNotepad_triggered()
{
QMessageBox::about(this, tr("About"),
tr("<b>Notepad 1.0.0</b>"));


Nhờ tải bản gốc

Tài liệu, ebook tham khảo khác

Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status