• 4243阅读
  • 2回复

[提问]Qt新手 [复制链接]

上一主题 下一主题
离线scutlpf
 
只看楼主 倒序阅读 楼主  发表于: 2013-03-14
— 本帖被 XChinux 从 论坛管理区 移动到本区(2013-03-14) —
  1. //Calculator.h
  2. #ifndef CALCULATOR_H
  3. #define CALCULATOR_H
  4. #include <QtGui>
  5. class Calculator : public QDialog
  6. {
  7.     Q_OBJECT
  8. public:
  9.     Calculator(QWidget *parent = 0);
  10. private:
  11.     void CreateButton();
  12.     QPushButton*ZERO;
  13.     QPushButton*ONE;
  14.     QPushButton*TWO;
  15.     QPushButton*THREE;
  16.     QPushButton*FOUR;
  17.     QPushButton*FIVE;
  18.     QPushButton*SIX;
  19.     QPushButton*SEVEN;
  20.     QPushButton*EIGHT;
  21.     QPushButton*NINE;
  22.     QPushButton*PI;
  23.     QPushButton*E;
  24.     QPushButton*ADD;
  25.     QPushButton*SUBTRACTION;
  26.     QPushButton*MULTIPLICATION;
  27.     QPushButton*DIVISION;
  28.     QPushButton*EQUALITY;
  29.     QPushButton*DOT;
  30.     QLineEdit*SCREEN;
  31. };
  32. #endif // CALCULATOR_H
  33. //Calculator.cpp
  34. #include "Calculator.h"
  35. Calculator::Calculator(QWidget*parent)
  36. {
  37.     CreateButton();
  38.     QVBoxLayout*V =  new QVBoxLayout;
  39.     QHBoxLayout*H1 =  new QHBoxLayout;
  40.     QHBoxLayout*H2 =  new QHBoxLayout;
  41.     QHBoxLayout*H3 =  new QHBoxLayout;
  42.     QHBoxLayout*H4 =  new QHBoxLayout;
  43.     QHBoxLayout*H5 =  new QHBoxLayout;
  44.     H1->addWidget(NINE);
  45.     H1->addWidget(EIGHT);
  46.     H1->addWidget(SEVEN);
  47.     H1->addWidget(SIX);
  48.     H2->addWidget(FIVE);
  49.     H2->addWidget(FOUR);
  50.     H2->addWidget(THREE);
  51.     H2->addWidget(TWO);
  52.     H3->addWidget(ONE);
  53.     H3->addWidget(ZERO);
  54.     H3->addWidget(PI);
  55.     H3->addWidget(E);
  56.     H4->addWidget(ADD);
  57.     H4->addWidget(SUBTRACTION);
  58.     H4->addWidget(MULTIPLICATION);
  59.     H4->addWidget(DIVISION);
  60.     H5->addWidget(DOT);
  61.     H5->addWidget(EQUALITY);
  62.     V->addWidget(SCREEN);
  63.     V->addLayout(H1);
  64.     V->addLayout(H2);
  65.     V->addLayout(H3);
  66.     V->addLayout(H4);
  67.     V->addLayout(H5);
  68.     setLayout(V);
  69. }
  70. void Calculator::CreateButton()
  71. {
  72.     ZERO = new QPushButton("0",this);
  73.     ONE = new QPushButton("1",this);
  74.     TWO = new QPushButton("2",this);
  75.     THREE = new QPushButton("3",this);
  76.     FOUR = new QPushButton("4",this);
  77.     FIVE = new QPushButton("5",this);
  78.     SIX = new QPushButton("6",this);
  79.     SEVEN = new QPushButton("7",this);
  80.     EIGHT = new QPushButton("8",this);
  81.     NINE = new QPushButton("9",this);
  82.     PI = new QPushButton("pi",this);
  83.     E = new QPushButton("e",this);
  84.     ADD = new QPushButton("+",this);
  85.     SUBTRACTION = new QPushButton("-",this);
  86.     MULTIPLICATION = new QPushButton("*",this);
  87.     DIVISION = new QPushButton("/",this);
  88.     EQUALITY = new QPushButton("=",this);
  89.     DOT = new QPushButton(".",this);
  90.     SCREEN = new QLineEdit(this);
  91. }
  92. //main.cpp
  93. #include <QApplication>
  94. #include "Calculator.h"
  95. int main(int argc,char*argv[])
  96. {
  97.     QApplication app(argc,argv);
  98.     Calculator calcu;
  99.     calcu.show();
  100.     return app.exec();
  101. }
编译后提示
Configuration unchanged, skipping QMake step.Starting: E:/Qt/mingw/bin/mingw32-make.exe debug -w mingw32-make: Entering directory `D:/Documents/Qt/Calculator'E:/Qt/mingw/bin/mingw32-make -f Makefile.Debugmingw32-make[1]: Entering directory `D:/Documents/Qt/Calculator'mingw32-make[1]: Nothing to be done for `first'.mingw32-make[1]: Leaving directory `D:/Documents/Qt/Calculator'mingw32-make: Leaving directory `D:/Documents/Qt/Calculator'Exited with code 0.


窗口闪了一下就消失了,帮帮忙!!!急求啊!!!!
坚持做一件事,坚持从小事做起
离线XChinux

只看该作者 1楼 发表于: 2013-03-14
文不对题,请先修改标题。
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线scutlpf
只看该作者 2楼 发表于: 2013-03-14
不好意思,刚使用论坛,还不太了解,多多包涵。
坚持做一件事,坚持从小事做起
快速回复
限100 字节
 
上一个 下一个