rozália szabó nacsa eötvös loránd university, budapest ...3 reads and writes reading generates...
TRANSCRIPT
![Page 1: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/1.jpg)
1
C++ GUI Programming with Qt 3
Rozália Szabó NacsaEötvös Loránd University, Budapest
![Page 2: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/2.jpg)
2
The Task
QMainWindow (RichEdit)
QTextEdit(textEdit)
![Page 3: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/3.jpg)
3
Reads and writesReadingGenerates#includesToolGenerated source fileRevision controlled source file
The “ui.h” extension approachQt
designer
UIC
richedit.cpprichedit.cppmain.cppmain.cpp
richedit.uirichedit.ui
richedit.hrichedit.h
Application specific functionsare given in the richedit.ui.h
implementation file.
Application specific functionsare given in the richedit.ui.h
implementation file.
richedit.ui.hrichedit.ui.h
![Page 4: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/4.jpg)
4
Creating a Project File
File/New …File/New …
3
1
2
3
![Page 5: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/5.jpg)
5
Creating a Main Window
File/New …File/New …1
2
3
![Page 6: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/6.jpg)
6
„Choose available menus and toolbars”page
![Page 7: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/7.jpg)
7
„Setup Toolbar” page
![Page 8: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/8.jpg)
8
RichEdit: Properties
![Page 9: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/9.jpg)
9
Save the project
Accept the name: richedit
File/Save…File/Save…
![Page 10: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/10.jpg)
10
Adding main program to the project
File/New …File/New …
![Page 11: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/11.jpg)
11
main.cpp
#include <qapplication.h>#include "richedit.h"
int main( int argc, char ** argv ){
QApplication a( argc, argv );RichEdit w;w.show();a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );return a.exec();
}
#include <qapplication.h>#include "richedit.h"
int main( int argc, char ** argv ){
QApplication a( argc, argv );RichEdit w;w.show();a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );return a.exec();
}
main.cppmain.cpp
The generated main.cppprogram
![Page 12: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/12.jpg)
12
Compile & Run
1. (qmake –project)2. qmake –o Makefile richedit.pro3. nmake4. richedit
1. (qmake –project)2. qmake –o Makefile richedit.pro3. nmake4. richedit
No slots, but it is still inthe menu.
![Page 13: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/13.jpg)
13
Preview – Ctrl+T
![Page 14: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/14.jpg)
14
Action Editor „in Action”
![Page 15: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/15.jpg)
15
Creating new Actions: Italic, Bold, Underlined Fonts
Right Click & …
A new actioon appears in he Action Editor.Properties are given in thenext slide.
![Page 16: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/16.jpg)
16
Properties of Bold Action
![Page 17: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/17.jpg)
17
Adding Pictures to the Project
![Page 18: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/18.jpg)
18
Properties of Font Actions
italicActionitalicAction
boldActionboldAction
underlineActionunderlineAction
![Page 19: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/19.jpg)
19
Creating Action Group: Alignment
![Page 20: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/20.jpg)
20
alignActionGroup’s properties
![Page 21: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/21.jpg)
21
Creating Actions within a GroupSelect thealignActionGroup, thenRight Click & …
1
2
![Page 22: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/22.jpg)
22
Properties of Align Actions
leftAlignActionleftAlignAction
rightAlignActionrightAlignAction
centerAlignActioncenterAlignAction
![Page 23: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/23.jpg)
23
Deleting unnecessary Actions
![Page 24: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/24.jpg)
24
Creating a Toolbar
Right Click at the right endof the toolbar.
![Page 25: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/25.jpg)
25
New ToolbarNew Toolbar
Drag & DropDrag & Drop
Select the action you want toadd to the toolbar, drag & drop & …
![Page 26: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/26.jpg)
26
Inserting separator into the toolbar
1.Right Click on a toolbar button (!!!)2. Insert Separator
1.Right Click on a toolbar button (!!!)2. Insert Separator
![Page 27: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/27.jpg)
27
Adding Font Actions to the Toolbar
Drag & DropDrag & Drop
![Page 28: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/28.jpg)
28
Creating a Font ComboBox on the Toolbar
Click on the ComboBoxClick on the ComboBox
Click on the Separator (!)Click on the Separator (!)
1
2
![Page 29: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/29.jpg)
29
Click on the SpinBoxClick on the SpinBox
Click on the ComboBox (!)Click on the ComboBox (!)
1
2
![Page 30: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/30.jpg)
30
SpinBox’s and ComboBox’s Properties
![Page 31: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/31.jpg)
31
Adding Menus to the Project
Right click on the menu barRight click on the menu bar1
2
![Page 32: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/32.jpg)
32
A new „Menu” in the Project
![Page 33: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/33.jpg)
33
Renaming menu text
Press F2 to edit the text.Press F2 to edit the text.
F&ormatF&ormat
![Page 34: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/34.jpg)
34
Insering alignActionGroup into Format Menu
Drag & Drag & DropDrag & Drag & Drop
1. Select alignActionGroup in ActionEditor
2. Keep press the left mouse button3. Keep pressing find the Format menu4. Keep pressing move down and find
the position of the submenu. (The redline shows the position.)
![Page 35: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/35.jpg)
35
Adding Separator to the Menu
Drag & DropDrag & Drop
![Page 36: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/36.jpg)
36
Drag & DropDrag & Drop
![Page 37: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/37.jpg)
37
Adding the Main Widget
QTextEdit (textEdit)
![Page 38: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/38.jpg)
38
textEdit’s properties
![Page 39: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/39.jpg)
39
Lay Out the Form
Click on the Form.(No selected widgets!)1
2
3
![Page 40: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/40.jpg)
40
Creating Connections to ChangeFontAttributes
Sender: boldActionSignal: toggled(bool)Receiver: textEditSlot: setBold(bool)
Sender: boldActionSignal: toggled(bool)Receiver: textEditSlot: setBold(bool)
Sender: italicActionSignal: toggled(bool)Receiver: textEditSlot: setItalic(bool)
Sender: italicActionSignal: toggled(bool)Receiver: textEditSlot: setItalic(bool)
Sender: underlineActionSignal: toggled(bool)Receiver: textEditSlot: setUnderline(bool)
Sender: underlineActionSignal: toggled(bool)Receiver: textEditSlot: setUnderline(bool)
![Page 41: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/41.jpg)
41
Using Documentation: QAction
![Page 42: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/42.jpg)
42
Using Documentation: QTextEdit
![Page 43: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/43.jpg)
43
Preview
These functions can be activated in different way.These functions can be activated in different way.
![Page 44: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/44.jpg)
44
Qt designer
UIC
richedit.cpprichedit.cppmain.cppmain.cpp
richedit.uirichedit.ui
richedit.hrichedit.h
richedit.ui.hrichedit.ui.h
![Page 45: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/45.jpg)
45
Defining „constructor”: init()
void RichEdit::init(){
textEdit->setFocus();}
void RichEdit::init(){
textEdit->setFocus();}
richedit.ui.hrichedit.ui.h
![Page 46: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/46.jpg)
46
New Slot: changeAlignment(QAction*)
Function: changeAlignment(QAction*)Return type: voidSpecifier: virtualAccess: publicType: slot
Function: changeAlignment(QAction*)Return type: voidSpecifier: virtualAccess: publicType: slot
![Page 47: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/47.jpg)
47
New Connection
Sender: alignActionGroupSignal: selected(QAction*)Receiver: RichEditSlot: changeAlignment(QAction*)
Sender: alignActionGroupSignal: selected(QAction*)Receiver: RichEditSlot: changeAlignment(QAction*)
![Page 48: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/48.jpg)
48
RichEdit::changeAlignment(QAction *action)
void RichEdit::changeAlignment( QAction * alignAction){
if (alignAction == leftAlignAction)textEdit->setAlignment(Qt::AlignLeft);
else if (alignAction == rightAlignAction)textEdit->setAlignment(Qt::AlignRight);
else if (alignAction == centerAlignAction)textEdit->setAlignment(Qt::AlignCenter);
}
void RichEdit::changeAlignment( QAction * alignAction){
if (alignAction == leftAlignAction)textEdit->setAlignment(Qt::AlignLeft);
else if (alignAction == rightAlignAction)textEdit->setAlignment(Qt::AlignRight);
else if (alignAction == centerAlignAction)textEdit->setAlignment(Qt::AlignCenter);
}
richedit.ui.hrichedit.ui.h
![Page 49: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/49.jpg)
49
New Function: saveAndContinue(const QString & action)
Function: saveAndContinue(const QString & action)Return type: intSpecifier: virtualAccess: protectedType: function
Function: saveAndContinue(const QString & action)Return type: intSpecifier: virtualAccess: protectedType: function
![Page 50: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/50.jpg)
50
RichEdit::saveAndContinue(const QString & action)
int RichEdit::saveAndContinue( const QString & action ) {int continueAction = 1;if ( textEdit->isModified() ) {
switch( QMessageBox::information(this, "Rich Edit","The document contains unsaved changes.\n""Do you want to save the changes?","&Save", "&Don't Save", "&Cancel " + action,0, // Enter == button 02 ) ) { // Escape == button 2
case 0: // Save; continuefileSave();break;
case 1: // Do not save; continuebreak;
case 2: // CancelcontinueAction = 0;break;
}}return continueAction;
}
int RichEdit::saveAndContinue( const QString & action ) {int continueAction = 1;if ( textEdit->isModified() ) {
switch( QMessageBox::information(this, "Rich Edit","The document contains unsaved changes.\n""Do you want to save the changes?","&Save", "&Don't Save", "&Cancel " + action,0, // Enter == button 02 ) ) { // Escape == button 2
case 0: // Save; continuefileSave();break;
case 1: // Do not save; continuebreak;
case 2: // CancelcontinueAction = 0;break;
}}return continueAction;
}
richedit.ui.hrichedit.ui.h
Includes (in Implementation):<qmessagebox.h>
Includes (in Implementation):<qmessagebox.h>
![Page 51: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/51.jpg)
51
New Function: saveAndContinue(const QString & action)
Function: saveAndContinue(const QString & action)Return type: intSpecifier: virtualAccess: protectedType: function
Function: saveAndContinue(const QString & action)Return type: intSpecifier: virtualAccess: protectedType: function
![Page 52: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/52.jpg)
52
RichEdit::saveAndContinue(const QString & action)
int RichEdit::saveAndContinue( const QString & action ) {int continueAction = 1;if ( textEdit->isModified() ) {
switch( QMessageBox::information(this, "Rich Edit","The document contains unsaved changes.\n""Do you want to save the changes?","&Save", "&Don't Save", "&Cancel " + action,0, // Enter == button 02 ) ) { // Escape == button 2
case 0: // Save; continuefileSave();break;
case 1: // Do not save; continuebreak;
case 2: // CancelcontinueAction = 0;break;
}}return continueAction;
}
int RichEdit::saveAndContinue( const QString & action ) {int continueAction = 1;if ( textEdit->isModified() ) {
switch( QMessageBox::information(this, "Rich Edit","The document contains unsaved changes.\n""Do you want to save the changes?","&Save", "&Don't Save", "&Cancel " + action,0, // Enter == button 02 ) ) { // Escape == button 2
case 0: // Save; continuefileSave();break;
case 1: // Do not save; continuebreak;
case 2: // CancelcontinueAction = 0;break;
}}return continueAction;
}
richedit.ui.hrichedit.ui.h
Includes (in Implementation):<qmessagebox.h>
Includes (in Implementation):<qmessagebox.h>
![Page 53: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/53.jpg)
53
Compile & Run
![Page 54: Rozália Szabó Nacsa Eötvös Loránd University, Budapest ...3 Reads and writes Reading Generates #includes Tool Generated source file Revision controlled source file The “ui.h”](https://reader035.vdocuments.mx/reader035/viewer/2022080722/5f7bc8610c68bf669110a483/html5/thumbnails/54.jpg)
54