summaryrefslogtreecommitdiffstats
path: root/examples/action
diff options
context:
space:
mode:
Diffstat (limited to 'examples/action')
-rw-r--r--examples/action/action.pro11
-rw-r--r--examples/action/application.cpp306
-rw-r--r--examples/action/application.doc36
-rw-r--r--examples/action/application.h46
-rw-r--r--examples/action/fileopen.xpm22
-rw-r--r--examples/action/fileprint.xpm24
-rw-r--r--examples/action/filesave.xpm22
-rw-r--r--examples/action/main.cpp20
-rw-r--r--examples/action/toggleaction/labelonoff.xpm169
-rw-r--r--examples/action/toggleaction/toggleaction.cpp31
-rw-r--r--examples/action/toggleaction/toggleaction.doc15
-rw-r--r--examples/action/toggleaction/toggleaction.pro10
12 files changed, 712 insertions, 0 deletions
diff --git a/examples/action/action.pro b/examples/action/action.pro
new file mode 100644
index 000000000..e780f7451
--- /dev/null
+++ b/examples/action/action.pro
@@ -0,0 +1,11 @@
+TEMPLATE = app
+TARGET = action
+
+CONFIG += qt warn_on release
+DEPENDPATH = ../../include
+
+REQUIRES = full-config
+
+HEADERS = application.h
+SOURCES = application.cpp \
+ main.cpp
diff --git a/examples/action/application.cpp b/examples/action/application.cpp
new file mode 100644
index 000000000..23a3a8755
--- /dev/null
+++ b/examples/action/application.cpp
@@ -0,0 +1,306 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include "application.h"
+
+#include <qimage.h>
+#include <qpixmap.h>
+#include <qtoolbar.h>
+#include <qtoolbutton.h>
+#include <qpopupmenu.h>
+#include <qmenubar.h>
+#include <qtextedit.h>
+#include <qfile.h>
+#include <qfiledialog.h>
+#include <qstatusbar.h>
+#include <qmessagebox.h>
+#include <qprinter.h>
+#include <qapplication.h>
+#include <qaccel.h>
+#include <qtextstream.h>
+#include <qpainter.h>
+#include <qpaintdevicemetrics.h>
+#include <qwhatsthis.h>
+#include <qaction.h>
+#include <qsimplerichtext.h>
+
+#include "filesave.xpm"
+#include "fileopen.xpm"
+#include "fileprint.xpm"
+
+
+ApplicationWindow::ApplicationWindow()
+ : TQMainWindow( 0, "example application main window", WDestructiveClose )
+{
+ printer = new TQPrinter( TQPrinter::HighResolution );
+
+ TQAction * fileNewAction;
+ TQAction * fileOpenAction;
+ TQAction * fileSaveAction, * fileSaveAsAction, * filePrintAction;
+ TQAction * fileCloseAction, * fileQuitAction;
+
+ fileNewAction = new TQAction( "&New", CTRL+Key_N, this, "new" );
+ connect( fileNewAction, SIGNAL( activated() ) , this,
+ SLOT( newDoc() ) );
+
+ fileOpenAction = new TQAction( TQPixmap( fileopen ), "&Open...",
+ CTRL+Key_O, this, "open" );
+ connect( fileOpenAction, SIGNAL( activated() ) , this, SLOT( choose() ) );
+
+ const char * fileOpenText = "<p><img source=\"fileopen\"> "
+ "Click this button to open a <em>new file</em>. <br>"
+ "You can also select the <b>Open</b> command "
+ "from the <b>File</b> menu.</p>";
+ TQMimeSourceFactory::defaultFactory()->setPixmap( "fileopen",
+ fileOpenAction->iconSet().pixmap() );
+ fileOpenAction->setWhatsThis( fileOpenText );
+
+ fileSaveAction = new TQAction( TQPixmap( filesave ),
+ "&Save", CTRL+Key_S, this, "save" );
+ connect( fileSaveAction, SIGNAL( activated() ) , this, SLOT( save() ) );
+
+ const char * fileSaveText = "<p>Click this button to save the file you "
+ "are editing. You will be prompted for a file name.\n"
+ "You can also select the <b>Save</b> command "
+ "from the <b>File</b> menu.</p>";
+ fileSaveAction->setWhatsThis( fileSaveText );
+
+ fileSaveAsAction = new TQAction( "Save File As", "Save &As...", 0, this,
+ "save as" );
+ connect( fileSaveAsAction, SIGNAL( activated() ) , this,
+ SLOT( saveAs() ) );
+ fileSaveAsAction->setWhatsThis( fileSaveText );
+
+ filePrintAction = new TQAction( "Print File", TQPixmap( fileprint ),
+ "&Print...", CTRL+Key_P, this, "print" );
+ connect( filePrintAction, SIGNAL( activated() ) , this,
+ SLOT( print() ) );
+
+ const char * filePrintText = "Click this button to print the file you "
+ "are editing.\n You can also select the Print "
+ "command from the File menu.";
+ filePrintAction->setWhatsThis( filePrintText );
+
+ fileCloseAction = new TQAction( "Close", "&Close", CTRL+Key_W, this,
+ "close" );
+ connect( fileCloseAction, SIGNAL( activated() ) , this,
+ SLOT( close() ) );
+
+ fileQuitAction = new TQAction( "Quit", "&Quit", CTRL+Key_Q, this,
+ "tquit" );
+ connect( fileQuitAction, SIGNAL( activated() ) , qApp,
+ SLOT( closeAllWindows() ) );
+
+ // populate a tool bar with some actions
+
+ TQToolBar * fileTools = new TQToolBar( this, "file operations" );
+ fileTools->setLabel( "File Operations" );
+ fileOpenAction->addTo( fileTools );
+ fileSaveAction->addTo( fileTools );
+ filePrintAction->addTo( fileTools );
+ (void)TQWhatsThis::whatsThisButton( fileTools );
+
+
+ // populate a menu with all actions
+
+ TQPopupMenu * file = new TQPopupMenu( this );
+ menuBar()->insertItem( "&File", file );
+ fileNewAction->addTo( file );
+ fileOpenAction->addTo( file );
+ fileSaveAction->addTo( file );
+ fileSaveAsAction->addTo( file );
+ file->insertSeparator();
+ filePrintAction->addTo( file );
+ file->insertSeparator();
+ fileCloseAction->addTo( file );
+ fileQuitAction->addTo( file );
+
+
+ menuBar()->insertSeparator();
+
+ // add a help menu
+
+ TQPopupMenu * help = new TQPopupMenu( this );
+ menuBar()->insertItem( "&Help", help );
+ help->insertItem( "&About", this, SLOT(about()), Key_F1 );
+ help->insertItem( "About &TQt", this, SLOT(aboutTQt()) );
+ help->insertSeparator();
+ help->insertItem( "What's &This", this, SLOT(whatsThis()),
+ SHIFT+Key_F1 );
+
+
+ // create and define the central widget
+
+ e = new TQTextEdit( this, "editor" );
+ e->setFocus();
+ setCentralWidget( e );
+ statusBar()->message( "Ready", 2000 );
+
+ resize( 450, 600 );
+}
+
+
+ApplicationWindow::~ApplicationWindow()
+{
+ delete printer;
+}
+
+
+
+void ApplicationWindow::newDoc()
+{
+ ApplicationWindow *ed = new ApplicationWindow;
+ ed->show();
+}
+
+void ApplicationWindow::choose()
+{
+ TQString fn = TQFileDialog::getOpenFileName( TQString::null, TQString::null,
+ this);
+ if ( !fn.isEmpty() )
+ load( fn );
+ else
+ statusBar()->message( "Loading aborted", 2000 );
+}
+
+
+void ApplicationWindow::load( const TQString &fileName )
+{
+ TQFile f( fileName );
+ if ( !f.open( IO_ReadOnly ) )
+ return;
+
+ TQTextStream ts( &f );
+ e->setText( ts.read() );
+ e->setModified( FALSE );
+ setCaption( fileName );
+ statusBar()->message( "Loaded document " + fileName, 2000 );
+}
+
+
+void ApplicationWindow::save()
+{
+ if ( filename.isEmpty() ) {
+ saveAs();
+ return;
+ }
+
+ TQString text = e->text();
+ TQFile f( filename );
+ if ( !f.open( IO_WriteOnly ) ) {
+ statusBar()->message( TQString("Could not write to %1").arg(filename),
+ 2000 );
+ return;
+ }
+
+ TQTextStream t( &f );
+ t << text;
+ f.close();
+
+ e->setModified( FALSE );
+
+ setCaption( filename );
+
+ statusBar()->message( TQString( "File %1 saved" ).arg( filename ), 2000 );
+}
+
+
+void ApplicationWindow::saveAs()
+{
+ TQString fn = TQFileDialog::getSaveFileName( TQString::null, TQString::null,
+ this );
+ if ( !fn.isEmpty() ) {
+ filename = fn;
+ save();
+ } else {
+ statusBar()->message( "Saving aborted", 2000 );
+ }
+}
+
+
+void ApplicationWindow::print()
+{
+ printer->setFullPage( TRUE );
+ if ( printer->setup(this) ) { // printer dialog
+ statusBar()->message( "Printing..." );
+ TQPainter p;
+ if( !p.begin( printer ) ) { // paint on printer
+ statusBar()->message( "Printing aborted", 2000 );
+ return;
+ }
+
+ TQPaintDeviceMetrics metrics( p.device() );
+ int dpiy = metrics.logicalDpiY();
+ int margin = (int) ( (2/2.54)*dpiy ); // 2 cm margins
+ TQRect view( margin, margin, metrics.width() - 2*margin, metrics.height() - 2*margin );
+ TQSimpleRichText richText( TQStyleSheet::convertFromPlainText(e->text()),
+ TQFont(),
+ e->context(),
+ e->styleSheet(),
+ e->mimeSourceFactory(),
+ view.height() );
+ richText.setWidth( &p, view.width() );
+ int page = 1;
+ do {
+ richText.draw( &p, margin, margin, view, colorGroup() );
+ view.moveBy( 0, view.height() );
+ p.translate( 0 , -view.height() );
+ p.drawText( view.right() - p.fontMetrics().width( TQString::number( page ) ),
+ view.bottom() + p.fontMetrics().ascent() + 5, TQString::number( page ) );
+ if ( view.top() - margin >= richText.height() )
+ break;
+ printer->newPage();
+ page++;
+ } while (TRUE);
+
+ statusBar()->message( "Printing completed", 2000 );
+ } else {
+ statusBar()->message( "Printing aborted", 2000 );
+ }
+}
+
+void ApplicationWindow::closeEvent( TQCloseEvent* ce )
+{
+ if ( !e->isModified() ) {
+ ce->accept();
+ return;
+ }
+
+ switch( TQMessageBox::information( this, "TQt Application Example",
+ "The document has been changed since "
+ "the last save.",
+ "Save Now", "Cancel", "Leave Anyway",
+ 0, 1 ) ) {
+ case 0:
+ save();
+ ce->accept();
+ break;
+ case 1:
+ default: // just for sanity
+ ce->ignore();
+ break;
+ case 2:
+ ce->accept();
+ break;
+ }
+}
+
+
+void ApplicationWindow::about()
+{
+ TQMessageBox::about( this, "TQt Application Example",
+ "This example demonstrates simple use of "
+ "TQMainWindow,\nTQMenuBar and TQToolBar.");
+}
+
+
+void ApplicationWindow::aboutTQt()
+{
+ TQMessageBox::aboutTQt( this, "TQt Application Example" );
+}
diff --git a/examples/action/application.doc b/examples/action/application.doc
new file mode 100644
index 000000000..f4eaaae44
--- /dev/null
+++ b/examples/action/application.doc
@@ -0,0 +1,36 @@
+/*
+*/
+
+/*! \page qaction-application-example.html
+
+ \ingroup qaction-examples
+
+
+ \title A Complete Application Window with Actions
+
+ The QAction class provides a way of associating user input from different
+ user interface elements with abstract high level actions. This approach makes
+ it easy to customize applications for different types of users.
+
+ This example program is just like the
+ <a href="simple-application-example.html">application example</a>,
+ but uses QAction to build the menu and the toolbar.
+
+ <hr>
+
+ Header file:
+
+ \include action/application.h
+
+ <hr>
+
+ Implementation:
+
+ \include action/application.cpp
+
+ <hr>
+
+ Main:
+
+ \include action/main.cpp
+*/
diff --git a/examples/action/application.h b/examples/action/application.h
new file mode 100644
index 000000000..7b772728e
--- /dev/null
+++ b/examples/action/application.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#ifndef APPLICATION_H
+#define APPLICATION_H
+
+#include <qmainwindow.h>
+
+class TQTextEdit;
+
+class ApplicationWindow: public TQMainWindow
+{
+ Q_OBJECT
+
+public:
+ ApplicationWindow();
+ ~ApplicationWindow();
+
+protected:
+ void closeEvent( TQCloseEvent* );
+
+private slots:
+ void newDoc();
+ void choose();
+ void load( const TQString &fileName );
+ void save();
+ void saveAs();
+ void print();
+
+ void about();
+ void aboutTQt();
+
+private:
+ TQPrinter *printer;
+ TQTextEdit *e;
+ TQString filename;
+};
+
+
+#endif
diff --git a/examples/action/fileopen.xpm b/examples/action/fileopen.xpm
new file mode 100644
index 000000000..880417eee
--- /dev/null
+++ b/examples/action/fileopen.xpm
@@ -0,0 +1,22 @@
+/* XPM */
+static const char *fileopen[] = {
+" 16 13 5 1",
+". c #040404",
+"# c #808304",
+"a c None",
+"b c #f3f704",
+"c c #f3f7f3",
+"aaaaaaaaa...aaaa",
+"aaaaaaaa.aaa.a.a",
+"aaaaaaaaaaaaa..a",
+"a...aaaaaaaa...a",
+".bcb.......aaaaa",
+".cbcbcbcbc.aaaaa",
+".bcbcbcbcb.aaaaa",
+".cbcb...........",
+".bcb.#########.a",
+".cb.#########.aa",
+".b.#########.aaa",
+"..#########.aaaa",
+"...........aaaaa"
+};
diff --git a/examples/action/fileprint.xpm b/examples/action/fileprint.xpm
new file mode 100644
index 000000000..6ada912fa
--- /dev/null
+++ b/examples/action/fileprint.xpm
@@ -0,0 +1,24 @@
+/* XPM */
+static const char *fileprint[] = {
+" 16 14 6 1",
+". c #000000",
+"# c #848284",
+"a c #c6c3c6",
+"b c #ffff00",
+"c c #ffffff",
+"d c None",
+"ddddd.........dd",
+"dddd.cccccccc.dd",
+"dddd.c.....c.ddd",
+"ddd.cccccccc.ddd",
+"ddd.c.....c....d",
+"dd.cccccccc.a.a.",
+"d..........a.a..",
+".aaaaaaaaaa.a.a.",
+".............aa.",
+".aaaaaa###aa.a.d",
+".aaaaaabbbaa...d",
+".............a.d",
+"d.aaaaaaaaa.a.dd",
+"dd...........ddd"
+};
diff --git a/examples/action/filesave.xpm b/examples/action/filesave.xpm
new file mode 100644
index 000000000..bd6870f47
--- /dev/null
+++ b/examples/action/filesave.xpm
@@ -0,0 +1,22 @@
+/* XPM */
+static const char *filesave[] = {
+" 14 14 4 1",
+". c #040404",
+"# c #808304",
+"a c #bfc2bf",
+"b c None",
+"..............",
+".#.aaaaaaaa.a.",
+".#.aaaaaaaa...",
+".#.aaaaaaaa.#.",
+".#.aaaaaaaa.#.",
+".#.aaaaaaaa.#.",
+".#.aaaaaaaa.#.",
+".##........##.",
+".############.",
+".##.........#.",
+".##......aa.#.",
+".##......aa.#.",
+".##......aa.#.",
+"b............."
+};
diff --git a/examples/action/main.cpp b/examples/action/main.cpp
new file mode 100644
index 000000000..215211630
--- /dev/null
+++ b/examples/action/main.cpp
@@ -0,0 +1,20 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include "application.h"
+
+int main( int argc, char ** argv ) {
+ TQApplication a( argc, argv );
+ ApplicationWindow * mw = new ApplicationWindow();
+ mw->setCaption( "Document 1" );
+ mw->show();
+ a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(tquit()) );
+ return a.exec();
+}
diff --git a/examples/action/toggleaction/labelonoff.xpm b/examples/action/toggleaction/labelonoff.xpm
new file mode 100644
index 000000000..87696d158
--- /dev/null
+++ b/examples/action/toggleaction/labelonoff.xpm
@@ -0,0 +1,169 @@
+/* XPM */
+static const char * labelonoff_xpm[] = {
+"32 32 134 2",
+" c None",
+". c #FFFFFF",
+"+ c #DEDEDE",
+"@ c #E7E7DE",
+"# c #E7E7E7",
+"$ c #EFEFDE",
+"% c #EFEFE7",
+"& c #F7F7DE",
+"* c #F7F7E7",
+"= c #DEDEE7",
+"- c #C6CEEF",
+"; c #B5B5E7",
+"> c #A5ADF7",
+", c #9CA5F7",
+"' c #8C94F7",
+") c #9C9CEF",
+"! c #BDBDE7",
+"~ c #8C8CEF",
+"{ c #7B7BEF",
+"] c #6B6BF7",
+"^ c #7373F7",
+"/ c #9494EF",
+"( c #DEDEEF",
+"_ c #A5ADFF",
+": c #6B7BFF",
+"< c #4A5AFF",
+"[ c #394AFF",
+"} c #424AF7",
+"| c #3142F7",
+"1 c #4252FF",
+"2 c #5A63F7",
+"3 c #3939F7",
+"4 c #0000FF",
+"5 c #E7E7EF",
+"6 c #9CA5FF",
+"7 c #3139E7",
+"8 c #424AD6",
+"9 c #7373D6",
+"0 c #8C8CCE",
+"a c #8C94CE",
+"b c #9494CE",
+"c c #8C8CD6",
+"d c #8484D6",
+"e c #6B6BD6",
+"f c #2121F7",
+"g c #4A52EF",
+"h c #5252EF",
+"i c #1818F7",
+"j c #C6CEFF",
+"k c #5A5AEF",
+"l c #0810FF",
+"m c #EFE7E7",
+"n c #7B84E7",
+"o c #3131F7",
+"p c #5263FF",
+"q c #7B84F7",
+"r c #1818FF",
+"s c #DEDED6",
+"t c #A5B5FF",
+"u c #848CF7",
+"v c #3939FF",
+"w c #3139EF",
+"x c #8C94EF",
+"y c #A5A5EF",
+"z c #D6D6D6",
+"A c #ADB5F7",
+"B c #7384FF",
+"C c #D6D6E7",
+"D c #2931FF",
+"E c #BDBDEF",
+"F c #C6CEE7",
+"G c #C6C6E7",
+"H c #525AF7",
+"I c #6B73EF",
+"J c #5A6BFF",
+"K c #949CF7",
+"L c #7B84FF",
+"M c #2129F7",
+"N c #0000EF",
+"O c #0808FF",
+"P c #1010FF",
+"Q c #6B6BEF",
+"R c #CECECE",
+"S c #BDBDDE",
+"T c #6B6BDE",
+"U c #4A52E7",
+"V c #2931EF",
+"W c #3942DE",
+"X c #8484EF",
+"Y c #A5A5E7",
+"Z c #CECEDE",
+"` c #A5A5D6",
+" . c #BDBDBD",
+".. c #EFEFEF",
+"+. c #F7F7EF",
+"@. c #8C8C94",
+"#. c #080821",
+"$. c #000008",
+"%. c #181818",
+"&. c #212129",
+"*. c #313131",
+"=. c #393939",
+"-. c #393942",
+";. c #424242",
+">. c #4A4A4A",
+",. c #4A4A52",
+"'. c #42424A",
+"). c #313139",
+"!. c #292931",
+"~. c #000000",
+"{. c #848484",
+"]. c #A5A5AD",
+"^. c #8C8C8C",
+"/. c #ADADAD",
+"(. c #B5B5BD",
+"_. c #7B7B7B",
+":. c #5A5A63",
+"<. c #292929",
+"[. c #6B6B6B",
+"}. c #949494",
+"|. c #F7F7F7",
+"1. c #A5A5A5",
+"2. c #5A5A5A",
+"3. c #636363",
+"4. c #7B7B84",
+"5. c #737373",
+"6. c #101010",
+"7. c #212121",
+"8. c #525252",
+"9. c #080808",
+"0. c #BDBDC6",
+"a. c #C6C6C6",
+"b. c #9C9C9C",
+"c. c #B5B5B5",
+". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
+". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
+". . . + @ # # @ @ $ # # # % $ # @ # @ % $ & $ $ * % % # # . . . ",
+". . . + = @ = - ; > , ' ' ' ) ! @ # ! ) ~ { ] ^ { / ! # @ . . . ",
+". . . + @ ( _ : < [ } } | | [ 1 2 3 4 4 4 4 4 4 4 4 4 3 ! . . . ",
+". . . + 5 6 7 8 9 0 a b c d e 7 4 4 4 f 3 g h g 3 f 4 4 i . . . ",
+". . . @ j g 0 @ $ % % % % $ & k 4 l { @ @ # $ m @ = ; h 4 . . . ",
+". . . + 6 n @ # + # + # # # # o f p q * # # # # # @ * % r . . . ",
+". . . s t u @ @ # @ # # # @ # v w ] x & @ # # @ # & % y 4 . . . ",
+". . . z A B / C = # # @ # # % ^ < D k E F = C C G ) H 4 4 . . . ",
+". . . s G I J : ' ' K , ' u L < M N N 4 4 O P O 4 4 4 4 Q . . . ",
+". . . R $ S T U } } } } | V V W 0 X 3 P 4 4 4 4 P f h Y % . . . ",
+". . . R # # @ Z ` a d d a ` S @ % % # = F ! ; G = = % % # . . . ",
+". . . ...# # # % * % * +.* % # # % # % % % * % % # % # # . . . ",
+". . . @.. . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
+". . #.$.%.&.*.=.-.-.;.;.;.>.>.>.,.>.>.>.>.'.;.;.;.-.-.).!.&.$.. ",
+". . ~.{.R R z z z z + + + + + + + + + + + + + + + s z z s z ].. ",
+". . ).z ^./.# # # # # + + + + # + + + # + + + @ + = # % (._.... ",
+". . :.^.~.^...+ + + + # # # + + # + # + # # @ = # @ # + *.<.... ",
+". . [.^.~.}.. # # # ....# ....+ # + ..|.# + = # ....# ..<.*.. . ",
+". . -.;.~.=._.+ # # 1.2.;.3./.# # # _.[.R # # + 4.5.R [.6.6.[.. ",
+". . <.%.~.%.;.+ # 2.~.7.>.%.~.{...# 5.~.8...+._.~.2.+ ;.~.9.=.. ",
+". . 5.}.~.^.|...{.~.[.....+ 8.~. ...# 8.~./.0.~.;.# % + 7.=.|.. ",
+". . 5.}.~.{.|.# =.9.+ ..# ..a.~.5.....z %.7.<.%.R ..# = %.=.|.. ",
+". . 5.}.~.{...+ 7.~.*.*.*.*.*.~.>.# # ../.~.~.1...# # @ %.=.|.. ",
+". . 5.b.~.{.|.+ %.6.8.8.8.8.8.2.^.+ # ..b.~.~.^...# # + %.=.|.. ",
+". . 5.b.~._.|.+ *.%...|.......a.+ # ..a.6.=.>.~.c...# + 6.;.. . ",
+". . 5./.~.5.. ..[.~.{.|...|.^.~.{...+ *.9.a.z 6.<.z ..+ 7.=.. . ",
+". . [.a.~.%.2.z + 7.~.2.}.3.~.7.z ..[.~._...|.{.~.8...# =.~.>.. ",
+". . 3.# {.<.%.c...z [.7.9.%.3.R ..R ;.2.+ # # # 3.;.a.../.;.<.. ",
+". . 3.= ..+ + # # # ..# s + ..# # + # # # + # # # # + # ....|.. ",
+". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . "};
diff --git a/examples/action/toggleaction/toggleaction.cpp b/examples/action/toggleaction/toggleaction.cpp
new file mode 100644
index 000000000..e9fcc5c49
--- /dev/null
+++ b/examples/action/toggleaction/toggleaction.cpp
@@ -0,0 +1,31 @@
+#include <qapplication.h>
+#include <qmainwindow.h>
+#include <qtoolbar.h>
+#include <qaction.h>
+
+#include "labelonoff.xpm"
+
+int main( int argc, char **argv )
+{
+ TQApplication app( argc, argv );
+ TQMainWindow * window = new TQMainWindow;
+ window->setCaption("TQt Example - Toggleaction");
+ TQToolBar * toolbar = new TQToolBar( window );
+
+ TQAction * labelonoffaction = new TQAction( window, "labelonoff" );
+ labelonoffaction->setToggleAction( TRUE );
+
+ labelonoffaction->setText( "labels on/off" );
+ labelonoffaction->setAccel( TQt::ALT+TQt::Key_L );
+ labelonoffaction->setIconSet( (TQPixmap) labelonoff_xpm );
+
+ TQObject::connect( labelonoffaction, SIGNAL( toggled( bool ) ),
+ window, SLOT( setUsesTextLabel( bool ) ) );
+
+ labelonoffaction->addTo( toolbar );
+
+ app.setMainWidget( window );
+ window->show();
+ return app.exec();
+}
+
diff --git a/examples/action/toggleaction/toggleaction.doc b/examples/action/toggleaction/toggleaction.doc
new file mode 100644
index 000000000..7924a2631
--- /dev/null
+++ b/examples/action/toggleaction/toggleaction.doc
@@ -0,0 +1,15 @@
+/*! \page toggleaction-example.html
+
+ \ingroup qaction-examples
+
+ \title A Tiny Example Featuring a Toggle Action
+
+ This example program demonstrates the use of QAction
+ in its incarnation as a toggle action.
+
+ <hr>
+
+ Main:
+
+ \include action/toggleaction/toggleaction.cpp
+*/
diff --git a/examples/action/toggleaction/toggleaction.pro b/examples/action/toggleaction/toggleaction.pro
new file mode 100644
index 000000000..697d7cd76
--- /dev/null
+++ b/examples/action/toggleaction/toggleaction.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+TARGET = toggleaction
+
+CONFIG += qt warn_on release
+DEPENDPATH = ../../../include
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = toggleaction.cpp