... connect(menu_3, SIGNAL(aboutToShow()), this, SLOT(f())); }public slots: void rasschet(); void about(); void aboutQt(); void f();
...void MainWindow::aboutQt(){qDebug() << "It's slot aboutQt";QMessageBox::about(this, tr("Qt"), tr("Qt Trolltech - Nokia."));}void MainWindow:: f(){ MainWindow::aboutQt();}
connect(menu_3, SIGNAL(aboutToHide()), this, SLOT(aboutQt()));
#ifndef UI_PROGA1_H#define UI_PROGA1_H#include <QtCore/QVariant>#include <QtGui/QAction>#include <QtGui/QApplication>#include <QtGui/QButtonGroup>#include <QtGui/QLabel>#include <QtGui/QMainWindow>#include <QtGui/QMenu>#include <QtGui/QMenuBar>#include <QtGui/QPushButton>#include <QtGui/QSpinBox>#include <QtGui/QStatusBar>#include <QtGui/QTextEdit>#include <QtGui/QWidget>class Ui_MainWindow{public: QAction *action_4; QAction *action_5; QAction *action_6; QAction *action_7; QAction *action_Ctrl_Q;QAction *aboutQtAct; QWidget *centralwidget; QSpinBox *spinBox; QTextEdit *textEdit; QPushButton *pushButton; QPushButton *pushButton_2; QLabel *label; QLabel *label_2; QStatusBar *statusbar; QMenuBar *menubar; QMenu *menu; QMenu *menu_2; //QMenu *menu_3; void setupUi(QMainWindow *MainWindow) { if (MainWindow->objectName().isEmpty()) MainWindow->setObjectName(QString::fromUtf8("MainWindow")); MainWindow->setWindowModality(Qt::ApplicationModal); MainWindow->setEnabled(true); MainWindow->resize(600, 600); MainWindow->setMinimumSize(QSize(385, 294)); MainWindow->setMaximumSize(QSize(600, 600)); action_4 = new QAction(MainWindow); action_4->setObjectName(QString::fromUtf8("action_4")); action_4->setCheckable(true); action_4->setChecked(true); action_5 = new QAction(MainWindow); action_5->setObjectName(QString::fromUtf8("action_5")); action_5->setCheckable(true); action_6 = new QAction(MainWindow); action_6->setObjectName(QString::fromUtf8("action_6")); action_7 = new QAction(MainWindow); action_7->setObjectName(QString::fromUtf8("action_7")); action_Ctrl_Q = new QAction(MainWindow); action_Ctrl_Q->setObjectName(QString::fromUtf8("action_Ctrl_Q"));aboutQtAct = new QAction(MainWindow); aboutQtAct->setObjectName(QString::fromUtf8("aboutQtAct")); centralwidget = new QWidget(MainWindow); centralwidget->setObjectName(QString::fromUtf8("centralwidget")); spinBox = new QSpinBox(centralwidget); spinBox->setObjectName(QString::fromUtf8("spinBox")); spinBox->setGeometry(QRect(50, 40, 161, 22)); spinBox->setMaximum(10000000); textEdit = new QTextEdit(centralwidget); textEdit->setObjectName(QString::fromUtf8("textEdit")); textEdit->setGeometry(QRect(50, 110, 301, 71)); pushButton = new QPushButton(centralwidget); pushButton->setObjectName(QString::fromUtf8("pushButton")); pushButton->setGeometry(QRect(250, 40, 101, 21)); pushButton_2 = new QPushButton(centralwidget); pushButton_2->setObjectName(QString::fromUtf8("pushButton_2")); pushButton_2->setGeometry(QRect(160, 210, 75, 23)); label = new QLabel(centralwidget); label->setObjectName(QString::fromUtf8("label")); label->setGeometry(QRect(50, 20, 500, 16)); label_2 = new QLabel(centralwidget); label_2->setObjectName(QString::fromUtf8("label_2")); label_2->setGeometry(QRect(50, 90, 151, 16)); MainWindow->setCentralWidget(centralwidget); statusbar = new QStatusBar(MainWindow); statusbar->setObjectName(QString::fromUtf8("statusbar")); MainWindow->setStatusBar(statusbar); menubar = new QMenuBar(MainWindow); menubar->setObjectName(QString::fromUtf8("menubar")); menubar->setGeometry(QRect(0, 0, 385, 22)); menu = new QMenu(menubar); menu->setObjectName(QString::fromUtf8("menu")); menu_2 = new QMenu(menubar); menu_2->setObjectName(QString::fromUtf8("menu_2")); //menu_3 = new QMenu(menubar); //menu_3->setObjectName(QString::fromUtf8("menu_3")); MainWindow->setMenuBar(menubar); QWidget::setTabOrder(spinBox, pushButton); QWidget::setTabOrder(pushButton, textEdit); QWidget::setTabOrder(textEdit, pushButton_2); menubar->addAction(menu->menuAction()); menubar->addAction(menu_2->menuAction()); //menubar->addAction(menu_3->menuAction());menubar->addAction(aboutQtAct); menu->addAction(action_6); menu->addAction(action_7); menu->addAction(action_Ctrl_Q); menu_2->addAction(action_4); menu_2->addAction(action_5); retranslateUi(MainWindow); QObject::connect(pushButton_2, SIGNAL(clicked()), MainWindow, SLOT(close())); QObject::connect(action_Ctrl_Q, SIGNAL(triggered()), MainWindow, SLOT(close())); QMetaObject::connectSlotsByName(MainWindow); } // setupUi void retranslateUi(QMainWindow *MainWindow) { MainWindow->setWindowTitle(QApplication::translate("MainWindow", "\320\237\321\200\320\276\320\263\321\200\320\260\320\274\320\274\320\260 \342\204\2261 :)", 0, QApplication::UnicodeUTF8)); action_4->setText(QApplication::translate("MainWindow", "\320\240\321\203\321\201\321\201\320\272\320\270\320\271", 0, QApplication::UnicodeUTF8)); action_5->setText(QApplication::translate("MainWindow", "\320\220\320\275\320\263\320\273\320\270\320\271\321\201\320\272\320\270\320\271", 0, QApplication::UnicodeUTF8)); action_6->setText(QApplication::translate("MainWindow", "\320\236 \320\277\321\200\320\276\320\263\321\200\320\260\320\274\320\274\320\265", 0, QApplication::UnicodeUTF8)); action_7->setText(QApplication::translate("MainWindow", "\320\236\320\261 \320\260\320\262\321\202\320\276\321\200\320\265", 0, QApplication::UnicodeUTF8)); action_Ctrl_Q->setText(QApplication::translate("MainWindow", "\320\222\321\213\321\205\320\276\320\264", 0, QApplication::UnicodeUTF8));aboutQtAct->setText(QApplication::translate("MainWindow", "\320\237\320\276\320\274\320\276\321\211\321\214", 0, QApplication::UnicodeUTF8)); pushButton->setText(QApplication::translate("MainWindow", "\320\240\320\260\321\201\321\201\321\207\320\270\321\202\320\260\321\202\321\214", 0, QApplication::UnicodeUTF8)); pushButton_2->setText(QApplication::translate("MainWindow", "\320\222\321\213\321\205\320\276\320\264", 0, QApplication::UnicodeUTF8)); label->setText(QApplication::translate("MainWindow", "\320\222\320\262\320\265\320\264\320\270\321\202\320\265 \320\272\320\276\320\273\320\270\321\207\320\265\321\201\321\202\320\262\320\276 \321\201\320\265\320\272\321\203\320\275\320\264", 0, QApplication::UnicodeUTF8)); label_2->setText(QApplication::translate("MainWindow", "\320\240\320\265\320\267\321\203\320\273\321\214\321\202\320\260\321\202 \321\200\320\260\320\261\320\276\321\202\321\213 \320\277\321\200\320\276\320\263\321\200\320\260\320\274\320\274\321\213", 0, QApplication::UnicodeUTF8)); menu->setTitle(QApplication::translate("MainWindow", "\320\244\320\260\320\271\320\273", 0, QApplication::UnicodeUTF8)); menu_2->setTitle(QApplication::translate("MainWindow", "\320\257\320\267\321\213\320\272", 0, QApplication::UnicodeUTF8)); /*menu_3->setTitle(QApplication::translate("MainWindow", "\320\237\320\276\320\274\320\276\321\211\321\214", 0, QApplication::UnicodeUTF8));*/ } // retranslateUi};namespace Ui { class MainWindow: public Ui_MainWindow {};} // namespace UiQT_END_NAMESPACE#endif // UI_PROGA1_H
... connect(aboutQtAct, SIGNAL(triggered()), this, SLOT(aboutQt()));
<RCC> <qresource prefix="photo" > <file>000000.jpeg</file> </qresource></RCC>
<?xml version="1.0" encoding="UTF-8"?><ui version="4.0"> <class>Author</class> <widget class="QWidget" name="Author"> <property name="enabled"> <bool>true</bool> </property> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>300</width> <height>220</height> </rect> </property> <property name="minimumSize"> <size> <width>300</width> <height>200</height> </size> </property> <property name="maximumSize"> <size> <width>300</width> <height>220</height> </size> </property> <property name="sizeIncrement"> <size> <width>0</width> <height>0</height> </size> </property> <property name="windowTitle"> <string>Об авторе</string> </property> <property name="styleSheet"> <string notr="true">image: url(:/photo/000000.jpeg);</string> </property> <widget class="QPushButton" name="pushButton"> <property name="geometry"> <rect> <x>110</x> <y>180</y> <width>75</width> <height>23</height> </rect> </property> <property name="text"> <string>Закрыть</string> </property> </widget> <widget class="QLabel" name="label"> <property name="geometry"> <rect> <x>170</x> <y>0</y> <width>101</width> <height>16</height> </rect> </property> <property name="text"> <string>Автор программы: </string> </property> </widget> <widget class="QLabel" name="label_2"> <property name="geometry"> <rect> <x>150</x> <y>30</y> <width>131</width> <height>16</height> </rect> </property> <property name="text"> <string>Денис Михайлович</string> </property> </widget> <widget class="QLabel" name="label_3"> <property name="geometry"> <rect> <x>150</x> <y>50</y> <width>121</width> <height>16</height> </rect> </property> <property name="text"> <string>студент группы ВМ-21</string> </property> </widget> <widget class="QLabel" name="label_4"> <property name="geometry"> <rect> <x>190</x> <y>140</y> <width>46</width> <height>14</height> </rect> </property> <property name="text"> <string>2009 год</string> </property> </widget> <widget class="QGraphicsView" name="graphicsView"> <property name="enabled"> <bool>true</bool> </property> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>140</width> <height>148</height> </rect> </property> <property name="minimumSize"> <size> <width>140</width> <height>148</height> </size> </property> <property name="maximumSize"> <size> <width>140</width> <height>148</height> </size> </property> <property name="acceptDrops"> <bool>true</bool> </property> <property name="toolTip"> <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/photo/000000.jpeg" /></p></body></html></string> </property> <property name="whatsThis"> <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/photo/000000.jpeg" /></p></body></html></string> </property> <property name="autoFillBackground"> <bool>false</bool> </property> <property name="styleSheet"> <string notr="true">background-image: url(:/photo/000000.jpeg);</string> </property> <property name="lineWidth"> <number>0</number> </property> </widget> </widget> <resources/> <connections> <connection> <sender>pushButton</sender> <signal>pressed()</signal> <receiver>Author</receiver> <slot>close()</slot> <hints> <hint type="sourcelabel"> <x>137</x> <y>191</y> </hint> <hint type="destinationlabel"> <x>142</x> <y>105</y> </hint> </hints> </connection> </connections></ui>
/********************************************************************************** Form generated from reading ui file 'proga1_author.ui'**** Created: Thu 19. Nov 01:20:49 2009** by: Qt User Interface Compiler version 4.4.3**** WARNING! All changes made in this file will be lost when recompiling ui file!********************************************************************************/#ifndef UI_PROGA1_AUTHOR_H#define UI_PROGA1_AUTHOR_H#include <QtCore/QVariant>#include <QtGui/QAction>#include <QtGui/QApplication>#include <QtGui/QButtonGroup>#include <QtGui/QGraphicsView>#include <QtGui/QLabel>#include <QtGui/QPushButton>#include <QtGui/QWidget>QT_BEGIN_NAMESPACEclass Ui_Author{public: QPushButton *pushButton; QLabel *label; QLabel *label_2; QLabel *label_3; QLabel *label_4; QGraphicsView *graphicsView; void setupUi(QWidget *Author) { if (Author->objectName().isEmpty()) Author->setObjectName(QString::fromUtf8("Author")); Author->setEnabled(true); Author->resize(300, 220); Author->setMinimumSize(QSize(300, 200)); Author->setMaximumSize(QSize(300, 220)); Author->setSizeIncrement(QSize(0, 0)); Author->setStyleSheet(QString::fromUtf8("image: url(:/photo/000000.jpeg);")); pushButton = new QPushButton(Author); pushButton->setObjectName(QString::fromUtf8("pushButton")); pushButton->setGeometry(QRect(110, 180, 75, 23)); label = new QLabel(Author); label->setObjectName(QString::fromUtf8("label")); label->setGeometry(QRect(170, 0, 101, 16)); label_2 = new QLabel(Author); label_2->setObjectName(QString::fromUtf8("label_2")); label_2->setGeometry(QRect(150, 30, 131, 16)); label_3 = new QLabel(Author); label_3->setObjectName(QString::fromUtf8("label_3")); label_3->setGeometry(QRect(150, 50, 121, 16)); label_4 = new QLabel(Author); label_4->setObjectName(QString::fromUtf8("label_4")); label_4->setGeometry(QRect(190, 140, 46, 14)); graphicsView = new QGraphicsView(Author); graphicsView->setObjectName(QString::fromUtf8("graphicsView")); graphicsView->setEnabled(true); graphicsView->setGeometry(QRect(0, 0, 140, 148)); graphicsView->setMinimumSize(QSize(140, 148)); graphicsView->setMaximumSize(QSize(140, 148)); graphicsView->setAcceptDrops(true); graphicsView->setAutoFillBackground(false); graphicsView->setStyleSheet(QString::fromUtf8("background-image: url(:/photo/000000.jpeg);")); graphicsView->setLineWidth(0); retranslateUi(Author); QObject::connect(pushButton, SIGNAL(pressed()), Author, SLOT(close())); QMetaObject::connectSlotsByName(Author); } // setupUi void retranslateUi(QWidget *Author) { Author->setWindowTitle(QApplication::translate("Author", "\320\236\320\261 \320\260\320\262\321\202\320\276\321\200\320\265", 0, QApplication::UnicodeUTF8)); pushButton->setText(QApplication::translate("Author", "\320\227\320\260\320\272\321\200\321\213\321\202\321\214", 0, QApplication::UnicodeUTF8)); label->setText(QApplication::translate("Author", "\320\220\320\262\321\202\320\276\321\200 \320\277\321\200\320\276\320\263\321\200\320\260\320\274\320\274\321\213: ", 0, QApplication::UnicodeUTF8)); label_2->setText(QApplication::translate("Author", "\320\234\321\203\321\205\320\270\320\275 \320\224\320\265\320\275\320\270\321\201 \320\234\320\270\321\205\320\260\320\271\320\273\320\276\320\262\320\270\321\207", 0, QApplication::UnicodeUTF8)); label_3->setText(QApplication::translate("Author", "\321\201\321\202\321\203\320\264\320\265\320\275\321\202 \320\263\321\200\321\203\320\277\320\277\321\213 \320\222\320\234-21", 0, QApplication::UnicodeUTF8)); label_4->setText(QApplication::translate("Author", "2009 \320\263\320\276\320\264", 0, QApplication::UnicodeUTF8));#ifndef QT_NO_TOOLTIP graphicsView->setToolTip(QApplication::translate("Author", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n""<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n""p, li { white-space: pre-wrap; }\n""</style></head><body style=\" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n""<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><img src=\":/photo/000000.jpeg\" /></p></body></html>", 0, QApplication::UnicodeUTF8));#endif // QT_NO_TOOLTIP#ifndef QT_NO_WHATSTHIS graphicsView->setWhatsThis(QApplication::translate("Author", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n""<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n""p, li { white-space: pre-wrap; }\n""</style></head><body style=\" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n""<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><img src=\":/photo/000000.jpeg\" /></p></body></html>", 0, QApplication::UnicodeUTF8));#endif // QT_NO_WHATSTHIS Q_UNUSED(Author); } // retranslateUi};namespace Ui { class Author: public Ui_Author {};} // namespace UiQT_END_NAMESPACE#endif // UI_PROGA1_AUTHOR_H
#include <QtGui>#include "proga1_author.h"MyAuthor::MyAuthor(QWidget *parent) : QWidget(parent){ setupUi(this); connect(pushButton, SIGNAL(pressed()), this, SLOT(close()));}
<RCC> <qresource> <file>photo/000000.jpeg</file> </qresource></RCC>