Qt4读书笔记15
来源:互联网 发布:软件项目招标书 编辑:程序博客网 时间:2024/05/07 17:13
多文档(MultipleDocuments)
#include <QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplicationapp(argc, argv);
MainWindowmainWin;
mainWin.show();
returnapp.exec();
}
这次创建MainWindow没有使用new .函数结束时MainWindow对象会自动销毁。
如果改为多窗口程序:
int main(int argc, char *argv[])
{
QApplicationapp(argc, argv);
MainWindow*mainWin = new MainWindow;
mainWin->show();
returnapp.exec();
}
File|new修改:
void MainWindow::newFile()
{
MainWindow*mainWin = new MainWindow;
mainWin->show();
}
奇怪的是我们没有保存window的指针,这没有什么问题,Qt保留了;
void MainWindow::createActions()
{
...
closeAction= new QAction(tr("&Close"), this);
closeAction->setShortcut(QKeySequence::Close);
closeAction->setStatusTip(tr("Closethis window"));
connect(closeAction,SIGNAL(trigged()), this, SLOT(close()));
exitAction= new QAction(tr("E&xit"), this);
exitAction->setSHortcut(tr("Ctrl+Q"));
exitAction->setStatusTip(tr("Exitthe application"));
connect(exitAction,SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
...
}
启动界面(splashscreens)
许多应用在启动是呈现一个启动界面。一些开发者使用启动界面装饰缓慢的启动,或者是市场部门满意。在Qt应用中增加启动界面是很容易的。
使用的类为QSplashScreen.QSplashScreen类显示在mainwindow前。能够在image上写一些信息来通知用户当前的进度。
int main(int argc, char *argv[])
{
QApplicationapp(argc, argv);
QSplashScreen*splash = new QSplashScreen;
splash->setPixmap(QPixmap(":/images/splash.png"));
splash->show();
Qt::AlignmenttopRight = Qt::AlignRight | Qt::AlignTop;
splash->showMessage(QObject::tr("Settingup the main window..."), topRight, Qt::white);
MainWindowmainWin;
splash->showMessage(QObject::tr("Loadingmodules..."), topRight, Qt::white);
loadModules();
splash->showMessage(QObject::tr("Establishingconnections..."), topRight, Qt::white);
establishConnections();
mainWin.show();
splash->finish(&mainWin);
deletesplash;
returnapp.exec();
}
- Qt4读书笔记15
- qt4读书笔记--layout mangement
- qt4读书笔记--event processing
- Qt4读书笔记1
- Qt4读书笔记2
- Qt4读书笔记3
- Qt4读书笔记4
- Qt4读书笔记5
- Qt4读书笔记6
- Qt4读书笔记7
- Qt4读书笔记8
- Qt4读书笔记9
- Qt4读书笔记10
- Qt4读书笔记11
- Qt4读书笔记12
- Qt4读书笔记13
- Qt4读书笔记14
- Qt4读书笔记5-make问题解决
- c# Windows 服务应用程序介绍
- php执行sql语句
- 精通 Grails: RESTful Grails
- 算法 学习
- IBM WebSphere sMash 简介,第 1 部分: 为 Web 应用程序构建 RESTful 服务
- Qt4读书笔记15
- 在Internet Explorer的标准上下文相关菜单中添加菜单项
- OpenSource 虚拟化工具
- 将pthread移植到windows
- 文件上传
- php结果集的分页
- 堆和栈的区别
- JAVA 初学者需看
- java九九乘法表