基于qt的文本编辑器程序源代码.docx

附录 文本编辑器代码 textedit.pro TEMPLATE = app TARGET = textedit CONFIG +=qtwarn_o n HEADERS = textedit.h SOURCES = textedit.cpp main .cpp RESOURCES+= textedit.qrc build_all:!build_pass { CONFIG -= build_all CONFIG += release } # in stall target.path= $$[QT_INSTALL_DEMOS]/textedit *.docsources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.html images *.doc sources.path= $$[QT_INSTALL_DEMOS]/textedit INSTALLS += target sources textedit.h #ifndef TEXTEDIT』 #defi neTEXTEDIT_H #i nclude QMai nWin dow #in cludeQM ap #in clude QPo in ter QT_FORWARD_DECLARE_CLASS(QActio n) QT_FORWARD_DECLARE_CLASS(QComboBox) QT_FORWARD_DECLARE_CLASS(QFo ntComboBox) QT_FORWARD_DECLARE_CLASS(QTextEdit) QT_FORWARD_DECLARE_CLASS(QTextCharFormat) QT_FORWARD_DECLARE_CLASS(QMe nu) classTextEdit: public QMainWindow { Q_OBJECT public: TextEdit(QWidget *pare nt = 0); protected: virtual void closeEvent(QCIoseEvente); private: void setupFileActions(); void setupEditActions(); void setupTextActions(); bool load(constQString f); bool maybeSave(); void setCurrentFileName(consQString fileName); private slots: void fileNew(); void fileOpen(); bool fileSave(); bool fileSaveAs(); void filePrint(); void filePrintPreview(); void filePrintPdf(); void textBold(); void textUnderline(); void textItalic(); void textFamily(constQString f); void textSize(constQString p); void textStyle(intstylelndex); void textColor(); void textAlign(QAction *a); void currentCharFormatChanged(consQTextCharFormatformat); void cursorPositi on Cha nged(); void clipboardDataChanged(); void about(); void printPreview(QPrinter*); private: void mergeFormatOnWordOrSelection(consQTextCharFormatformat); void fontChanged(constQFontf); void colorChanged(constQColor c); void alignmentChanged(Qt::Alignmenta); QActio n *acti on Save, *act ion TextBold, *act ion TextU nderl ine, *act ion TextItalic, *act ion TextColor, *actio nAlig nLeft, *actio nAlig nCen ter, *act ion Alig nRight, *act ion Alig nJ ustify, *act ionUn do, *act ion Redo, *action Cut, *act

文档评论(0)

1亿VIP精品文档

相关文档