Starting today, we began using QT to do two more practical things, this article we mainly explore the following implementation of this editor.
First, let's look at our general framework:
Class Mainwindow:public Qmainwindow
{
q_object public
:
MainWindow ();
Protected:
void Closeevent (Qcloseevent *event);
For all defined signal and slot classes, the O_object macro at the beginning of the class definition is required.
Private slots:
void NewFile ();
void open ();
bool Save ();
BOOL SaveAs ();
void about ();
void Documentwasmodified ();
Private slots include creating new files, opening files, saving files, and about. Of course, we also have one of the most important functions in the program documentwasmodified (), the realization of the common ing function is to determine whether the file was modified.
Private:void createactions ();
void Createmenus ();
void Createtoolbars ();
void Createstatusbar ();
void Readsettings ();
void Writesettings ();
BOOL Maybesave ();
void LoadFile (const QString &filename);
BOOL SaveFile (const QString &filename);
void Setcurrentfile (const QString &filename);
QString strippedname (const QString &fullfilename);
Qtextedit *textedit;
QString Curfile;
Qmenu *filemenu;
Qmenu *editmenu;
Qmenu *formmenu;
Qmenu *helpmenu;
Qtoolbar *filetoolbar;
Qtoolbar *edittoolbar;
Qaction *newact;
Qaction *openact;
Qaction *saveact;
Qaction *saveasact;
Qaction *exitact;
Qaction *automaticact;
Qaction *typefaceact;
Qaction *cutact;
Qaction *copyact; Qaction*pasteact;
Qaction *aboutact;
Qaction *aboutqtact; };