Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4192319
  • 博文数量: 776
  • 博客积分: 13014
  • 博客等级: 上将
  • 技术积分: 10391
  • 用 户 组: 普通用户
  • 注册时间: 2010-02-22 17:00
文章分类

全部博文(776)

文章存档

2015年(55)

2014年(43)

2013年(147)

2012年(20)

2011年(82)

2010年(429)

分类: LINUX

2013-07-29 13:23:26

1. 在Qt Creator中根据向导生成Dialog工程HelloQtDialog。
2. 在HelloQtDialog.h增加蓝色字体代码
#ifndef HELLOQTDIALOG_H
#define HELLOQTDIALOG_H

#include

#include >
#include

namespace Ui {
class HelloQtDialog;
}

class HelloQtDialog : public QDialog {
Q_OBJECT
public:
HelloQtDialog(QWidget *parent = 0);
~HelloQtDialog();

protected:
void changeEvent(QEvent *e);

private:
Ui::HelloQtDialog *ui;
QVBoxLayout* layout;
QMenuBar* menuBar;
QAction* actionNew;
};

#endif // HELLOQTDIALOG_H

3. 在HelloQtDialog.cpp增加蓝色字体代码,至于slot和signal对应关系就不写了

HelloQtDialog::HelloQtDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::HelloQtDialog)
{
ui->setupUi(this);

layout = new QVBoxLayout(this);
menuBar = new QMenuBar(this);
menuBar->setGeometry(QRect(0, 0, 400, 24));
QMenu* menu = menuBar->addMenu(tr("&File"));
actionNew = menu->addAction(tr("&New"));
actionNew->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N));

layout->setMenuBar(menuBar);
setLayout(layout);

}

4. 编译运行:

5. 特殊说明:此方式对 Qt for Symbian 工程并不适用,不清楚是我搞错了还是 Qt for Symbian 的bug,至少我在S60 3rd SDK FP1 Emulator上测试不可以。

阅读(2146) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~