-
UID:5019
-
- 注册时间2006-03-26
- 最后登录2018-01-24
- 在线时间115小时
-
- 发帖125
- 搜Ta的帖子
- 精华0
- 金钱1330
- 威望134
- 贡献值0
- 好评度133
-
访问TA的空间加好友用道具
|
我的程序界面是在QtDesigner生成的ui_untitled.h的基础上加入自己的代码形成的。不过我一直没办法实现主菜单里File->Exit的功能,即使我次次编译都通过也没用。我可是已经把点击菜单的信号与QMainwindow的close()槽连接上了啊,就是代码里的这一句: - connect(action_X, SIGNAL(triggered()), this, SLOT(close()));
我把有关的代码帖出来吧(不好意思,里面的无用信息比较多) - #ifndef UNTITLED_H
- #define UNTITLED_H
- #include <QtCore/QVariant>
- #include <QtGui/QAction>
- #include <QtGui/QApplication>
- #include <QtGui/QButtonGroup>
- #include <QtGui/QGroupBox>
- #include <QtGui/QHBoxLayout>
- #include <QtGui/QLabel>
- #include <QtGui/QMainWindow>
- #include <QtGui/QMenu>
- #include <QtGui/QMenuBar>
- #include <QtGui/QRadioButton>
- #include <QtGui/QStatusBar>
- #include <QtGui/QVBoxLayout>
- #include <QtGui/QWidget>
- #include <qwt_wheel.h>
- #include <qwt_knob.h>
- #include "myplot.h"
- #include <qwt_data.h>
- #include "myscaledraw.h"
- using namespace std;
- class Ui_MainWindow:public QMainWindow
- {
- Q_OBJECT
- signals:
- void situationChanged();
- public:
- QAction *action_A;
- QAction *action_X;
- QAction *action_Q;
- QWidget *centralwidget;
- QWidget *widget;
- QHBoxLayout *hboxLayout;
- QGroupBox *groupBox;
- QLabel *label;
- QLabel *label_2;
- QGroupBox *groupBox_3;
- QWidget *widget1;
- QVBoxLayout *vboxLayout;
- QRadioButton *radioButton_5;
- QRadioButton *radioButton_2;
- QRadioButton *radioButton;
- QwtKnob *Knob;
- QwtWheel *wheel;
- QwtWheel *wheel_2;
- QwtWheel *wheel_3;
- QGroupBox *groupBox_2;
- QLabel *label_3;
- QLabel *label_4;
- QGroupBox *groupBox_4;
- QWidget *layoutWidget;
- QVBoxLayout *vboxLayout1;
- QRadioButton *radioButton_6;
- QRadioButton *radioButton_3;
- QRadioButton *radioButton_4;
- QwtKnob *Knob_2;
- QGroupBox *groupBox_5;
- QLabel *label_6;
- QLabel *label_5;
- QwtKnob *Knob_3;
- MyPlot *qwtPlot;
- QMenuBar *menubar;
- QMenu *menu_H;
- QMenu *menu_F;
- QStatusBar *statusbar;
- myscaleDraw *draw;
- QFont font;
-
-
- void setupUi(QMainWindow *MainWindow)
- {
- MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
-
- action_A = new QAction(MainWindow);
- action_A->setObjectName(QString::fromUtf8("action_A"));
- action_X = new QAction(MainWindow);
- action_X->setObjectName(QString::fromUtf8("action_X"));
- action_X->setShortcut(tr("Ctrl+Q"));
- action_X->setStatusTip(tr("Exit the application"));
- action_Q = new QAction(MainWindow);
- action_Q->setObjectName(QString::fromUtf8("action_Q"));
- centralwidget = new QWidget(MainWindow);
- centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
- widget = new QWidget(centralwidget);
- widget->setObjectName(QString::fromUtf8("widget"));
- widget->setGeometry(QRect(590, 10, 260, 301));
- hboxLayout = new QHBoxLayout(widget);
- hboxLayout->setSpacing(6);
- hboxLayout->setMargin(0);
- hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
- groupBox = new QGroupBox(widget);
- groupBox->setObjectName(QString::fromUtf8("groupBox"));
- groupBox->setAlignment(Qt::AlignHCenter);
- label = new QLabel(groupBox);
- label->setObjectName(QString::fromUtf8("label"));
- label->setGeometry(QRect(40, 19, 54, 15));
- label_2 = new QLabel(groupBox);
- label_2->setObjectName(QString::fromUtf8("label_2"));
- label_2->setGeometry(QRect(44, 65, 41, 16));
- groupBox_3 = new QGroupBox(groupBox);
- groupBox_3->setObjectName(QString::fromUtf8("groupBox_3"));
- groupBox_3->setGeometry(QRect(30, 185, 71, 111));
- widget1 = new QWidget(groupBox_3);
- widget1->setObjectName(QString::fromUtf8("widget1"));
- widget1->setGeometry(QRect(11, 22, 50, 77));
- vboxLayout = new QVBoxLayout(widget1);
- vboxLayout->setSpacing(6);
- vboxLayout->setMargin(0);
- vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
- radioButton_5 = new QRadioButton(widget1);
- radioButton_5->setObjectName(QString::fromUtf8("radioButton_5"));
- radioButton_5->setDown(false);
- vboxLayout->addWidget(radioButton_5);
- radioButton_2 = new QRadioButton(widget1);
- radioButton_2->setObjectName(QString::fromUtf8("radioButton_2"));
- radioButton_2->setDown(true);
-
- vboxLayout->addWidget(radioButton_2);
- radioButton = new QRadioButton(widget1);
- radioButton->setObjectName(QString::fromUtf8("radioButton"));
- radioButton->setDown(false);
- vboxLayout->addWidget(radioButton);
- myscaleDraw *draw=new myscaleDraw();
- font.setPointSize(7);
- Knob = new QwtKnob(groupBox);
- Knob->setGeometry(QRect(10, 76, 110, 110));
- Knob->setObjectName(QString::fromUtf8("Knob"));
- Knob->setOrientation(Qt::Horizontal);
- Knob->setScaleDraw(draw);
- Knob->setScale(0.0,10.0,1.0);
- Knob->setScaleMaxMinor(0);
- Knob->setRange(0.0,10.0,1.0);
- Knob->setValue(8.0);
- Knob->setFont(font);
- wheel = new QwtWheel(groupBox);
- wheel->setObjectName(QString::fromUtf8("wheel"));
- wheel->setGeometry(QRect(14, 36, 100, 24));
- wheel->setOrientation(Qt::Horizontal);
- wheel->setRange(-1.0,1.0,0.05);
-
- hboxLayout->addWidget(groupBox);
- groupBox_2 = new QGroupBox(widget);
- groupBox_2->setObjectName(QString::fromUtf8("groupBox_2"));
- groupBox_2->setAlignment(Qt::AlignHCenter);
- wheel_2 = new QwtWheel(groupBox_2);
- wheel_2->setObjectName(QString::fromUtf8("wheel_2"));
- wheel_2->setGeometry(QRect(14, 36, 100, 24));
- wheel_2->setOrientation(Qt::Horizontal);
- wheel_2->setRange(-1.0,1.0,0.05);
- label_3 = new QLabel(groupBox_2);
- label_3->setObjectName(QString::fromUtf8("label_3"));
- label_3->setGeometry(QRect(40, 19, 54, 15));
- label_4 = new QLabel(groupBox_2);
- label_4->setObjectName(QString::fromUtf8("label_4"));
- label_4->setGeometry(QRect(44, 65, 41, 16));
- groupBox_4 = new QGroupBox(groupBox_2);
- groupBox_4->setObjectName(QString::fromUtf8("groupBox_4"));
- groupBox_4->setGeometry(QRect(30, 185, 71, 111));
- layoutWidget = new QWidget(groupBox_4);
- layoutWidget->setObjectName(QString::fromUtf8("layoutWidget"));
- layoutWidget->setGeometry(QRect(11, 21, 50, 77));
- vboxLayout1 = new QVBoxLayout(layoutWidget);
- vboxLayout1->setSpacing(6);
- vboxLayout1->setMargin(0);
- vboxLayout1->setObjectName(QString::fromUtf8("vboxLayout1"));
- radioButton_6 = new QRadioButton(layoutWidget);
- radioButton_6->setObjectName(QString::fromUtf8("radioButton_6"));
- radioButton_6->setDown(false);
-
- vboxLayout1->addWidget(radioButton_6);
- radioButton_3 = new QRadioButton(layoutWidget);
- radioButton_3->setObjectName(QString::fromUtf8("radioButton_3"));
- radioButton_3->setDown(true);
- vboxLayout1->addWidget(radioButton_3);
- radioButton_4 = new QRadioButton(layoutWidget);
- radioButton_4->setObjectName(QString::fromUtf8("radioButton_4"));
- radioButton_4->setDown(false);
- vboxLayout1->addWidget(radioButton_4);
- Knob_2 = new QwtKnob(groupBox_2);
- Knob_2->setGeometry(QRect(10, 76, 110, 110));
- Knob_2->setObjectName(QString::fromUtf8("Knob_2"));
- Knob_2->setOrientation(Qt::Horizontal);
- Knob_2->setScaleDraw(draw);
- Knob_2->setScale(0.0,10.0,1.0);
- Knob_2->setScaleMaxMinor(0);
- Knob_2->setRange(0.0,10.0,1.0);
- Knob_2->setValue(8.0);
- Knob_2->setFont(font);
- hboxLayout->addWidget(groupBox_2);
- groupBox_5 = new QGroupBox(centralwidget);
- groupBox_5->setObjectName(QString::fromUtf8("groupBox_5"));
- groupBox_5->setGeometry(QRect(860, 10, 130, 176));
- groupBox_5->setAlignment(Qt::AlignHCenter);
- label_6 = new QLabel(groupBox_5);
- label_6->setObjectName(QString::fromUtf8("label_6"));
- label_6->setGeometry(QRect(41, 20, 54, 15));
- label_5 = new QLabel(groupBox_5);
- label_5->setObjectName(QString::fromUtf8("label_5"));
- label_5->setGeometry(QRect(45, 65, 41, 16));
- wheel_3 = new QwtWheel(groupBox_5);
- wheel_3->setObjectName(QString::fromUtf8("wheel_3"));
- wheel_3->setGeometry(QRect(34, 36, 64, 24));
- wheel_3->setOrientation(Qt::Horizontal);
- wheel_3->setRange(-1.0,1.0,0.05);
- Knob_3 = new QwtKnob(groupBox_5);
- Knob_3->setGeometry(QRect(12, 76, 110, 110));
- Knob_3->setObjectName(QString::fromUtf8("Knob_3"));
- Knob_3->setOrientation(Qt::Horizontal);
- Knob_3->setScaleDraw(draw);
- Knob_3->setScale(0.0,10.0,1.0);
- Knob_3->setScaleMaxMinor(0);
- Knob_3->setRange(0.0,10.0,1.0);
- Knob_3->setValue(8.0);
- Knob_3->setFont(font);
- qwtPlot = new MyPlot(centralwidget);
- qwtPlot->setObjectName(QString::fromUtf8("qwtPlot"));
- qwtPlot->setGeometry(QRect(10, 10, 550, 360));
- qwtPlot->setAutoReplot(false);
- qwtPlot->setProperty("xBottomAxis", QVariant(false));
- qwtPlot->setProperty("yLeftAxis", QVariant(false));
- MainWindow->setCentralWidget(centralwidget);
- menubar = new QMenuBar(MainWindow);
- menubar->setObjectName(QString::fromUtf8("menubar"));
- menubar->setGeometry(QRect(0, 0, 800, 27));
- menu_H = new QMenu(menubar);
- menu_H->setObjectName(QString::fromUtf8("menu_H"));
- menu_F = new QMenu(menubar);
- menu_F->setObjectName(QString::fromUtf8("menu_F"));
- MainWindow->setMenuBar(menubar);
- statusbar = new QStatusBar(MainWindow);
- statusbar->setObjectName(QString::fromUtf8("statusbar"));
- statusbar->setGeometry(QRect(0, 580, 800, 20));
- MainWindow->setStatusBar(statusbar);
- MainWindow->showMaximized();
- menubar->addAction(menu_F->menuAction());
- menubar->addAction(menu_H->menuAction());
- menu_F->addAction(action_X);
- menu_H->addAction(action_A);
- menu_H->addAction(action_Q);
- retranslateUi(MainWindow);
- connect(action_X, SIGNAL(triggered()), this, SLOT(close()));
- connect(wheel ,SIGNAL(valueChanged(double)),qwtPlot, SLOT(x_position(double)));
- connect(wheel_2,SIGNAL(valueChanged(double)),qwtPlot,SLOT(y_position(double)));
- connect(wheel_3,SIGNAL(valueChanged(double)),qwtPlot,SLOT(t_position(double)));
- connect(Knob,SIGNAL(valueChanged(double)),qwtPlot,SLOT(x_scale(double)));
- connect(Knob_2,SIGNAL(valueChanged(double)),qwtPlot,SLOT(y_scale(double)));
- connect(Knob_3,SIGNAL(valueChanged(double)),qwtPlot,SLOT(t_scale(double)));
- connect(radioButton_5,SIGNAL(clicked()),qwtPlot,SLOT(x_onclicked()));
- connect(radioButton_2,SIGNAL(clicked()),qwtPlot,SLOT(x_offclicked()));
- connect(radioButton ,SIGNAL(clicked()),qwtPlot,SLOT(x_zeroclicked()));
- connect(radioButton_6,SIGNAL(clicked()),qwtPlot,SLOT(y_onclicked()));
- connect(radioButton_3,SIGNAL(clicked()),qwtPlot,SLOT(y_offclicked()));
- connect(radioButton_4,SIGNAL(clicked()),qwtPlot,SLOT(y_zeroclicked()));
- connect(wheel ,SIGNAL(valueChanged(double)),this,SIGNAL(situationChanged()));
- connect(wheel_2,SIGNAL(valueChanged(double)),this,SIGNAL(situationChanged()));
- connect(wheel_3,SIGNAL(valueChanged(double)),this,SIGNAL(situationChanged()));
- connect(Knob, SIGNAL(valueChanged(double)),this,SIGNAL(situationChanged()));
- connect(Knob_2,SIGNAL(valueChanged(double)),this,SIGNAL(situationChanged()));
- connect(Knob_3,SIGNAL(valueChanged(double)),this,SIGNAL(situationChanged()));
- connect(radioButton_5,SIGNAL(clicked()),this,SIGNAL(situationChanged()));
- connect(radioButton_2,SIGNAL(clicked()),this,SIGNAL(situationChanged()));
- connect(radioButton ,SIGNAL(clicked()),this,SIGNAL(situationChanged()));
- connect(radioButton_6,SIGNAL(clicked()),this,SIGNAL(situationChanged()));
- connect(radioButton_3,SIGNAL(clicked()),this,SIGNAL(situationChanged()));
- connect(radioButton_4,SIGNAL(clicked()),this,SIGNAL(situationChanged()));
- connect(this, SIGNAL(situationChanged()),qwtPlot,SLOT(setposition()));
- QMetaObject::connectSlotsByName(MainWindow);
- } // setupUi
-
- void retranslateUi(QMainWindow *MainWindow)
- {
- MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8));
- action_X->setText(QApplication::translate("MainWindow", "E&xit", 0, QApplication::UnicodeUTF8));
- action_A->setText(QApplication::translate("MainWindow", "&About", 0, QApplication::UnicodeUTF8));
- action_Q->setText(QApplication::translate("MainWindow", "About &Qt", 0, QApplication::UnicodeUTF8));
- groupBox->setTitle(QApplication::translate("MainWindow", "Channe1", 0, QApplication::UnicodeUTF8));
- label->setText(QApplication::translate("MainWindow", "Position", 0, QApplication::UnicodeUTF8));
- label_2->setText(QApplication::translate("MainWindow", "Scale/V", 0, QApplication::UnicodeUTF8));
- groupBox_3->setTitle(QApplication::translate("MainWindow", "GroupBox", 0, QApplication::UnicodeUTF8));
- radioButton_5->setText(QApplication::translate("MainWindow", "On", 0, QApplication::UnicodeUTF8));
- radioButton_2->setText(QApplication::translate("MainWindow", "Off", 0, QApplication::UnicodeUTF8));
- radioButton->setText(QApplication::translate("MainWindow", "Zero", 0, QApplication::UnicodeUTF8));
- groupBox_2->setTitle(QApplication::translate("MainWindow", "Channel2", 0, QApplication::UnicodeUTF8));
- label_3->setText(QApplication::translate("MainWindow", "Position", 0, QApplication::UnicodeUTF8));
- label_4->setText(QApplication::translate("MainWindow", "Scale/V", 0, QApplication::UnicodeUTF8));
- groupBox_4->setTitle(QApplication::translate("MainWindow", "GroupBox", 0, QApplication::UnicodeUTF8));
- radioButton_6->setText(QApplication::translate("MainWindow", "On", 0, QApplication::UnicodeUTF8));
- radioButton_3->setText(QApplication::translate("MainWindow", "Off", 0, QApplication::UnicodeUTF8));
- radioButton_4->setText(QApplication::translate("MainWindow", "Zero", 0, QApplication::UnicodeUTF8));
- groupBox_5->setTitle(QApplication::translate("MainWindow", "TimeBase", 0, QApplication::UnicodeUTF8));
- label_6->setText(QApplication::translate("MainWindow", "Position", 0, QApplication::UnicodeUTF8));
- label_5->setText(QApplication::translate("MainWindow", "Scale/s", 0, QApplication::UnicodeUTF8));
- menu_H->setTitle(QApplication::translate("MainWindow", "&Help", 0, QApplication::UnicodeUTF8));
- menu_F->setTitle(QApplication::translate("MainWindow", "&File", 0, QApplication::UnicodeUTF8));
- } // retranslateUi
- };
-
- namespace Ui {
- class MainWindow: public Ui_MainWindow {};
- } // namespace Ui
- #endif // UNTITLED_H
[ 此贴被chwoozy在2006-05-28 20:39重新编辑 ]
|