A<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B%2FQt%2FQToolBar</id>
		<title>C++/Qt/QToolBar - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B%2FQt%2FQToolBar"/>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C%2B%2B/Qt/QToolBar&amp;action=history"/>
		<updated>2026-04-18T18:31:57Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.cppe.ru/index.php?title=C%2B%2B/Qt/QToolBar&amp;diff=1154&amp;oldid=prev</id>
		<title> в 14:21, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C%2B%2B/Qt/QToolBar&amp;diff=1154&amp;oldid=prev"/>
				<updated>2010-05-25T14:21:06Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 14:21, 25 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.cppe.ru/index.php?title=C%2B%2B/Qt/QToolBar&amp;diff=1155&amp;oldid=prev</id>
		<title>Admin: 1 версия:&amp;#32;Импорт контента...</title>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C%2B%2B/Qt/QToolBar&amp;diff=1155&amp;oldid=prev"/>
				<updated>2010-05-25T10:24:58Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия: Импорт контента...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==SdiWindow with toolbar and menubar==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;  &lt;br /&gt;
Foundations of Qt Development\Chapter04\sdi\main.cpp&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 2006-2007, Johan Thelin&lt;br /&gt;
 * &lt;br /&gt;
 * All rights reserved.&lt;br /&gt;
 * &lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without modification, &lt;br /&gt;
 * are permitted provided that the following conditions are met:&lt;br /&gt;
 * &lt;br /&gt;
 *     * Redistributions of source code must retain the above copyright notice, &lt;br /&gt;
 *       this list of conditions and the following disclaimer.&lt;br /&gt;
 *     * Redistributions in binary form must reproduce the above copyright notice,  &lt;br /&gt;
 *       this list of conditions and the following disclaimer in the documentation &lt;br /&gt;
 *       and/or other materials provided with the distribution.&lt;br /&gt;
 *     * Neither the name of APress nor the names of its contributors &lt;br /&gt;
 *       may be used to endorse or promote products derived from this software &lt;br /&gt;
 *       without specific prior written permission.&lt;br /&gt;
 * &lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT&lt;br /&gt;
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR&lt;br /&gt;
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR&lt;br /&gt;
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,&lt;br /&gt;
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR&lt;br /&gt;
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF&lt;br /&gt;
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING&lt;br /&gt;
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS&lt;br /&gt;
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
#include &amp;lt;QApplication&amp;gt;&lt;br /&gt;
#include &amp;quot;sdiwindow.h&amp;quot;&lt;br /&gt;
int main( int argc, char **argv )&lt;br /&gt;
{&lt;br /&gt;
  QApplication app( argc, argv );&lt;br /&gt;
  &lt;br /&gt;
  (new SdiWindow)-&amp;gt;show();&lt;br /&gt;
  &lt;br /&gt;
  return app.exec();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Foundations of Qt Development\Chapter04\sdi\sdiwindow.cpp&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 2006-2007, Johan Thelin&lt;br /&gt;
 * &lt;br /&gt;
 * All rights reserved.&lt;br /&gt;
 * &lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without modification, &lt;br /&gt;
 * are permitted provided that the following conditions are met:&lt;br /&gt;
 * &lt;br /&gt;
 *     * Redistributions of source code must retain the above copyright notice, &lt;br /&gt;
 *       this list of conditions and the following disclaimer.&lt;br /&gt;
 *     * Redistributions in binary form must reproduce the above copyright notice,  &lt;br /&gt;
 *       this list of conditions and the following disclaimer in the documentation &lt;br /&gt;
 *       and/or other materials provided with the distribution.&lt;br /&gt;
 *     * Neither the name of APress nor the names of its contributors &lt;br /&gt;
 *       may be used to endorse or promote products derived from this software &lt;br /&gt;
 *       without specific prior written permission.&lt;br /&gt;
 * &lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT&lt;br /&gt;
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR&lt;br /&gt;
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR&lt;br /&gt;
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,&lt;br /&gt;
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR&lt;br /&gt;
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF&lt;br /&gt;
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING&lt;br /&gt;
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS&lt;br /&gt;
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
#include &amp;lt;QApplication&amp;gt;&lt;br /&gt;
#include &amp;lt;QMenuBar&amp;gt;&lt;br /&gt;
#include &amp;lt;QToolBar&amp;gt;&lt;br /&gt;
#include &amp;lt;QStatusBar&amp;gt;&lt;br /&gt;
#include &amp;lt;QCloseEvent&amp;gt;&lt;br /&gt;
#include &amp;lt;QMessageBox&amp;gt;&lt;br /&gt;
#include &amp;lt;QTextEdit&amp;gt;&lt;br /&gt;
#include &amp;quot;sdiwindow.h&amp;quot;&lt;br /&gt;
SdiWindow::SdiWindow( QWidget *parent ) : QMainWindow( parent )&lt;br /&gt;
{&lt;br /&gt;
  setAttribute( Qt::WA_DeleteOnClose );&lt;br /&gt;
  setWindowTitle( tr(&amp;quot;%1[*] - %2&amp;quot; ).arg(tr(&amp;quot;unnamed&amp;quot;)).arg(tr(&amp;quot;SDI&amp;quot;)) );&lt;br /&gt;
  docWidget = new QTextEdit( this );&lt;br /&gt;
  setCentralWidget( docWidget );&lt;br /&gt;
  connect( docWidget-&amp;gt;document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool)) );&lt;br /&gt;
  &lt;br /&gt;
  createActions();&lt;br /&gt;
  createMenus();&lt;br /&gt;
  createToolbars();&lt;br /&gt;
  statusBar()-&amp;gt;showMessage( tr(&amp;quot;Done&amp;quot;) );&lt;br /&gt;
}&lt;br /&gt;
  &lt;br /&gt;
void SdiWindow::closeEvent( QCloseEvent *event )&lt;br /&gt;
{&lt;br /&gt;
  if( isSafeToClose() )&lt;br /&gt;
    event-&amp;gt;accept();&lt;br /&gt;
  else&lt;br /&gt;
    event-&amp;gt;ignore();&lt;br /&gt;
}&lt;br /&gt;
bool SdiWindow::isSafeToClose()&lt;br /&gt;
{&lt;br /&gt;
  if( isWindowModified() ) &lt;br /&gt;
  {&lt;br /&gt;
    switch( QMessageBox::warning( this, tr(&amp;quot;SDI&amp;quot;), &lt;br /&gt;
      tr(&amp;quot;The document has unsaved changes.\n&amp;quot;&lt;br /&gt;
         &amp;quot;Do you want to save it before it is closed?&amp;quot;), &lt;br /&gt;
         QMessageBox::Discard | QMessageBox::Cancel ) )&lt;br /&gt;
    {&lt;br /&gt;
    case QMessageBox::Cancel:&lt;br /&gt;
      return false;&lt;br /&gt;
    default:&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  return true;&lt;br /&gt;
}&lt;br /&gt;
  &lt;br /&gt;
void SdiWindow::fileNew()&lt;br /&gt;
{&lt;br /&gt;
  (new SdiWindow())-&amp;gt;show();&lt;br /&gt;
}&lt;br /&gt;
void SdiWindow::helpAbout()&lt;br /&gt;
{&lt;br /&gt;
  QMessageBox::about( this, tr(&amp;quot;About SDI&amp;quot;), tr(&amp;quot;A single document interface application.&amp;quot;) );&lt;br /&gt;
}&lt;br /&gt;
void SdiWindow::createActions()&lt;br /&gt;
{&lt;br /&gt;
  newAction = new QAction( QIcon(&amp;quot;:/images/new.png&amp;quot;), tr(&amp;quot;&amp;amp;New&amp;quot;), this );&lt;br /&gt;
  newAction-&amp;gt;setShortcut( tr(&amp;quot;Ctrl+N&amp;quot;) );&lt;br /&gt;
  newAction-&amp;gt;setStatusTip( tr(&amp;quot;Create a new document&amp;quot;) );&lt;br /&gt;
  connect( newAction, SIGNAL(triggered()), this, SLOT(fileNew()) );&lt;br /&gt;
  closeAction = new QAction( tr(&amp;quot;&amp;amp;Close&amp;quot;), this );&lt;br /&gt;
  closeAction-&amp;gt;setShortcut( tr(&amp;quot;Ctrl+W&amp;quot;) );&lt;br /&gt;
  closeAction-&amp;gt;setStatusTip( tr(&amp;quot;Close this document&amp;quot;) );&lt;br /&gt;
  connect( closeAction, SIGNAL(triggered()), this, SLOT(close()) );&lt;br /&gt;
  exitAction = new QAction( tr(&amp;quot;E&amp;amp;xit&amp;quot;), this );&lt;br /&gt;
  exitAction-&amp;gt;setShortcut( tr(&amp;quot;Ctrl+Q&amp;quot;) );&lt;br /&gt;
  exitAction-&amp;gt;setStatusTip( tr(&amp;quot;Quit the application&amp;quot;) );&lt;br /&gt;
  connect( exitAction, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()) );&lt;br /&gt;
  &lt;br /&gt;
  cutAction = new QAction( QIcon(&amp;quot;:/images/cut.png&amp;quot;), tr(&amp;quot;Cu&amp;amp;t&amp;quot;), this );&lt;br /&gt;
  cutAction-&amp;gt;setShortcut( tr(&amp;quot;Ctrl+X&amp;quot;) );&lt;br /&gt;
  cutAction-&amp;gt;setStatusTip( tr(&amp;quot;Cut&amp;quot;) );&lt;br /&gt;
  cutAction-&amp;gt;setEnabled(false);&lt;br /&gt;
  connect( docWidget, SIGNAL(copyAvailable(bool)), cutAction, SLOT(setEnabled(bool)) );&lt;br /&gt;
  connect( cutAction, SIGNAL(triggered()), docWidget, SLOT(cut()) );&lt;br /&gt;
  &lt;br /&gt;
  copyAction = new QAction( QIcon(&amp;quot;:/images/copy.png&amp;quot;), tr(&amp;quot;&amp;amp;Copy&amp;quot;), this );&lt;br /&gt;
  copyAction-&amp;gt;setShortcut( tr(&amp;quot;Ctrl+C&amp;quot;) );&lt;br /&gt;
  copyAction-&amp;gt;setStatusTip( tr(&amp;quot;Copy&amp;quot;) );&lt;br /&gt;
  copyAction-&amp;gt;setEnabled(false);&lt;br /&gt;
  connect( docWidget, SIGNAL(copyAvailable(bool)), copyAction, SLOT(setEnabled(bool)) );&lt;br /&gt;
  connect( copyAction, SIGNAL(triggered()), docWidget, SLOT(copy()) );&lt;br /&gt;
  pasteAction = new QAction( QIcon(&amp;quot;:/images/paste.png&amp;quot;), tr(&amp;quot;&amp;amp;Paste&amp;quot;), this );&lt;br /&gt;
  pasteAction-&amp;gt;setShortcut( tr(&amp;quot;Ctrl+V&amp;quot;) );&lt;br /&gt;
  pasteAction-&amp;gt;setStatusTip( tr(&amp;quot;Paste&amp;quot;) );&lt;br /&gt;
  connect( pasteAction, SIGNAL(triggered()), docWidget, SLOT(paste()) );&lt;br /&gt;
  &lt;br /&gt;
  aboutAction = new QAction( tr(&amp;quot;&amp;amp;About&amp;quot;), this );&lt;br /&gt;
  aboutAction-&amp;gt;setStatusTip( tr(&amp;quot;About this application&amp;quot;) );&lt;br /&gt;
  connect( aboutAction, SIGNAL(triggered()), this, SLOT(helpAbout()) );&lt;br /&gt;
  aboutQtAction = new QAction( tr(&amp;quot;About &amp;amp;Qt&amp;quot;), this );&lt;br /&gt;
  aboutQtAction-&amp;gt;setStatusTip( tr(&amp;quot;About the Qt toolkit&amp;quot;) );&lt;br /&gt;
  connect( aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()) );&lt;br /&gt;
}&lt;br /&gt;
void SdiWindow::createMenus()&lt;br /&gt;
{&lt;br /&gt;
  QMenu *menu;&lt;br /&gt;
  &lt;br /&gt;
  menu = menuBar()-&amp;gt;addMenu( tr(&amp;quot;&amp;amp;File&amp;quot;) );&lt;br /&gt;
  menu-&amp;gt;addAction( newAction );&lt;br /&gt;
  menu-&amp;gt;addAction( closeAction );&lt;br /&gt;
  menu-&amp;gt;addSeparator();&lt;br /&gt;
  menu-&amp;gt;addAction( exitAction );&lt;br /&gt;
  &lt;br /&gt;
  menu = menuBar()-&amp;gt;addMenu( tr(&amp;quot;&amp;amp;Edit&amp;quot;) );&lt;br /&gt;
  menu-&amp;gt;addAction( cutAction );&lt;br /&gt;
  menu-&amp;gt;addAction( copyAction );&lt;br /&gt;
  menu-&amp;gt;addAction( pasteAction );&lt;br /&gt;
  &lt;br /&gt;
  menu = menuBar()-&amp;gt;addMenu( tr(&amp;quot;&amp;amp;Help&amp;quot;) );&lt;br /&gt;
  menu-&amp;gt;addAction( aboutAction );&lt;br /&gt;
  menu-&amp;gt;addAction( aboutQtAction );&lt;br /&gt;
}&lt;br /&gt;
void SdiWindow::createToolbars()&lt;br /&gt;
{&lt;br /&gt;
  QToolBar *toolbar;&lt;br /&gt;
  &lt;br /&gt;
  toolbar = addToolBar( tr(&amp;quot;File&amp;quot;) );&lt;br /&gt;
  toolbar-&amp;gt;addAction( newAction );&lt;br /&gt;
  &lt;br /&gt;
  toolbar = addToolBar( tr(&amp;quot;Edit&amp;quot;) );&lt;br /&gt;
  toolbar-&amp;gt;addAction( cutAction );&lt;br /&gt;
  toolbar-&amp;gt;addAction( copyAction );&lt;br /&gt;
  toolbar-&amp;gt;addAction( pasteAction );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Foundations of Qt Development\Chapter04\sdi\sdiwindow.h&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 2006-2007, Johan Thelin&lt;br /&gt;
 * &lt;br /&gt;
 * All rights reserved.&lt;br /&gt;
 * &lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without modification, &lt;br /&gt;
 * are permitted provided that the following conditions are met:&lt;br /&gt;
 * &lt;br /&gt;
 *     * Redistributions of source code must retain the above copyright notice, &lt;br /&gt;
 *       this list of conditions and the following disclaimer.&lt;br /&gt;
 *     * Redistributions in binary form must reproduce the above copyright notice,  &lt;br /&gt;
 *       this list of conditions and the following disclaimer in the documentation &lt;br /&gt;
 *       and/or other materials provided with the distribution.&lt;br /&gt;
 *     * Neither the name of APress nor the names of its contributors &lt;br /&gt;
 *       may be used to endorse or promote products derived from this software &lt;br /&gt;
 *       without specific prior written permission.&lt;br /&gt;
 * &lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT&lt;br /&gt;
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR&lt;br /&gt;
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR&lt;br /&gt;
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,&lt;br /&gt;
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR&lt;br /&gt;
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF&lt;br /&gt;
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING&lt;br /&gt;
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS&lt;br /&gt;
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
#ifndef SDIWINDOW_H&lt;br /&gt;
#define SDIWINDOW_H&lt;br /&gt;
#include &amp;lt;QMainWindow&amp;gt;&lt;br /&gt;
class QAction;&lt;br /&gt;
class QTextEdit;&lt;br /&gt;
class SdiWindow : public QMainWindow&lt;br /&gt;
{&lt;br /&gt;
  Q_OBJECT&lt;br /&gt;
  &lt;br /&gt;
public:&lt;br /&gt;
  SdiWindow( QWidget *parent = 0 );&lt;br /&gt;
  &lt;br /&gt;
protected:&lt;br /&gt;
  void closeEvent( QCloseEvent *event );&lt;br /&gt;
  &lt;br /&gt;
private slots:&lt;br /&gt;
  void fileNew();&lt;br /&gt;
  void helpAbout();&lt;br /&gt;
private:&lt;br /&gt;
  void createActions();&lt;br /&gt;
  void createMenus();&lt;br /&gt;
  void createToolbars();&lt;br /&gt;
  bool isSafeToClose();&lt;br /&gt;
  QTextEdit *docWidget;&lt;br /&gt;
  &lt;br /&gt;
  QAction *newAction;&lt;br /&gt;
  QAction *closeAction;&lt;br /&gt;
  QAction *exitAction;&lt;br /&gt;
  &lt;br /&gt;
  QAction *cutAction;&lt;br /&gt;
  QAction *copyAction;&lt;br /&gt;
  QAction *pasteAction;&lt;br /&gt;
  &lt;br /&gt;
  QAction *aboutAction;&lt;br /&gt;
  QAction *aboutQtAction;&lt;br /&gt;
};&lt;br /&gt;
  &lt;br /&gt;
#endif // SDIWINDOW_H&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>