Qt学习笔记0405
2016-04-05 18:25
447 查看
#include <QtGui> #include <QMessageBox> #include <QApplication> #include <QInputDialog> int main (int argc, char* argv[]) { //1 QApplication app(argc, argv); //2 QTextStream cout(stdout); //3 int answer = 0; //4 do { int factArg = 0; int fact(1); factArg = QInputDialog::getInt(0, "Factorial Calculator", "Factorial of:", 1); //5 cout << "User entered: " << factArg << endl; int i=2; while (i <= factArg) { fact = fact * i; ++i; } QString response = QString("The factorial of %1 is %2.\n%3") .arg(factArg).arg(fact) .arg("Compute another factorial?"); //6 answer = QMessageBox::question(0, "Play again?", response, QMessageBox::Yes | QMessageBox::No); //7 } while (answer == QMessageBox::Yes); //8 return EXIT_SUCCESS; } /* 1 主函数的开始,并返回int 2 所有GUI应用的开端 3 创建模拟的标准输出cout 4 用于DO循环的判定 5 定义一个整型数据输入对话框(QInputDialog::getInt) 6 .arg可作为替换符,arg()将替换QString中的 %n (%1 %2 %3 ...%9) 7 信息框其中一种:QMessageBox::question的形式 8 通过位运算来判定循环条件 */
相关文章推荐
- QT学习 第一章:基本对话框
- 使用Shiboken为C++和Qt库创建Python绑定
- Qt 5.6更新至RC版,最终版本近在咫尺
- Qt定时器和随机数详解
- Qt实现图片移动实例(图文教程)
- Qt for Android开发实例教程
- QModelIndex/Role/Model介紹<二>
- 基于PyQt5的快速开发框架QFramer
- OSX下安装PyQt
- ok6410开发板移植DirectFB手记
- 【笔记】给Qt内嵌一个Chrome吧
- 【算法】最短路径之A*搜索
- qt入门必备
- 在 Qt4 中使用 C++11
- Hello Word ~ v0.2.2 背单词软件发布 -- By WHYPRO
- ubuntu下opencv和qt的安装配置
- linux下opengl的安装(with qt)
- qt 学习小节
- QT编译时Cannot find -lGL
- QT的命名风格