Qt Text Editor (top)

Source: Internet
Author: User
Tags bool class definition

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; };

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.