16,240
社区成员
发帖
与我相关
我的任务
分享
codeOrderComm::COrderComm(QWidget *parent)
: QMainWindow(parent)
{
menubar = new QMenuBar(this);
menubar->setObjectName(QString::fromUtf8("menubar"));
this->setMenuBar(menubar);
createMyMenu();
}
void COrderComm::createMyMenu()
{ //add menu item help to menu
menu_helpAction = new QAction(tr("订购"), this);
menuBar()->addAction(menu_helpAction);
connect(menu_helpAction, SIGNAL(triggered()), this, SLOT(helpAction()));
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QMenuBar *mb=new QMenuBar(this);
this->setMenuBar(mb);
QMenu *m1=new QMenu("1",mb);
QMenu *m2=new QMenu("1",mb);
mb->addMenu(m1);
mb->addMenu(m2);
}
mainwindow::mainwindow(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
QAction* hello = menuBar()->addAction(tr("Hello"));
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QAction* hello = menuBar()->addAction(tr("Hello"));
// QAction* hello = ui->menuBar->addAction(tr("Hello"));
connect(hello, SIGNAL(triggered()), this, SLOT(sayHello()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void MainWindow::sayHello()
{
QMessageBox mbox;
mbox.setText("Hello");
mbox.exec();
}
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget"/>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>19</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
COrderComm::COrderComm(QWidget *parent)
: QMainWindow(parent)
{
setWindowTitle(tr("金叶移动商务业务代理平台"));
setWindowIcon(QIcon(":/images/icon.png"));
QAction* menu_helpAction = menuBar()->addAction(tr("aaa"));
connect(menu_helpAction, SIGNAL(triggered()), this, SLOT(helpAction()));
}