QT开发平台
我在ubuntu下面安装了一个QT开发工具,但是后面进入QT Creator后,直接运行example都不行,我主要目的是
在源文件有的情况下,可以运行出一个出来,这是一个的猜数字游戏(网上下载的)
main.cpp
newfile.cpp
newfile.h
如果安装了LinuxQT的大神,希望能帮我建立一个工程,把工程打包发送给我一下,谢谢了,或者曾经做的小游戏发送给我也行。非常感谢。邮箱1971445763@qq.com
在源文件有的情况下,可以运行出一个出来,这是一个的猜数字游戏(网上下载的)
main.cpp
#include <QApplication>
#include "newfile.h"
//
int main(int argc, char ** argv)
{
QApplication app( argc, argv );
mywidget win;
win.show();
return app.exec();
}
newfile.cpp
#include <QtGui>
#include "newfile.h"
mywidget::mywidget(QWidget* parent):QWidget(parent)
{
label=new QLabel("time:");
addButton=new QPushButton("Input");
newButton=new QPushButton("New");
edit=new QLineEdit();
edittime=new QLineEdit("1");
edittime->setReadOnly(true);
val = rand() % 99 + 0;
time=1;
connect( addButton,SIGNAL(clicked()),this,SLOT(estimate()));
connect( newButton,SIGNAL(clicked()),this,SLOT(newgame()));
QHBoxLayout *HLayout = new QHBoxLayout;
HLayout->addWidget(label);
HLayout->addWidget(edittime);
QVBoxLayout *VLayout = new QVBoxLayout;
VLayout->addLayout(HLayout);
VLayout->addWidget( edit);
VLayout->addWidget(addButton);
VLayout->addWidget(newButton);
setLayout(VLayout);
setWindowTitle(QObject::trUtf8("猜数字了"));//设置标题
}
void mywidget::estimate()
{ QString stemp;
float ltemp;
ltemp=edit->text().toFloat();
stemp=QString::number(time);
edittime->setText(stemp);
time++;
if(ltemp>val)
{
QMessageBox::about(this, tr("Message"),
QObject::trUtf8("<h2>大了</h2>"));
}
if(ltemp<val)
{
QMessageBox::about(this, tr("Message"),
QObject::trUtf8("<h2>小了</h2>"));
}
if(ltemp==val)
{
QMessageBox::about(this, tr("Message"),
QObject::trUtf8("<h2>猜对了!!</h2>"));
}
}
void mywidget::newgame()
{
QString stemp;
time=1;
stemp=QString::number(time);
edittime->setText(stemp);
edit->setText("");
val = rand() % 99 + 0;
}
newfile.h
#ifndef __NEWFILE_H__
#define __NEWFILE_H__
#include <QWidget>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QApplication>
#include <QLabel>
#include <QObject>
class QLineEdit;
class QTextEdit;
class QPushButton;
class mywidget:public QWidget
{
Q_OBJECT
public:
mywidget(QWidget* parent=0);
private slots:
void estimate();
void newgame();
private:
QPushButton* addButton;
QPushButton* newButton;
QLabel* label;
QLineEdit *edittime;
QLineEdit *edit;
int val ;
int time;
};
#endif // __NEWFILE_H__
如果安装了LinuxQT的大神,希望能帮我建立一个工程,把工程打包发送给我一下,谢谢了,或者曾经做的小游戏发送给我也行。非常感谢。邮箱1971445763@qq.com
...全文
相关推荐
基于Linux操作系统的Qt开发平台的搭建.pdf
"基于Linux操作系统的Qt开发平台的搭建"本文主要介绍了基于Linux操作系统的Qt开发平台的搭建,旨在帮助开发者快速搭建Qt开发环境,实现跨平台的图形用户界面应用程序的开发。
linux 图形界面开发 Qt4开发平台搭建
### Linux图形界面开发Qt4开发平台搭建#### 1. 了解Qt开发平台Qt是一个跨平台的应用程序框架,主要用于创建高性能的用户界面组件。
基于Qt的嵌入式GUI开发平台的搭建
基于Qt的嵌入式GUI开发平台的搭建基于Qt的嵌入式GUI开发平台的搭建毕业论文
Ubuntu+QT+VTK+Eclipse&QtCreator开发平台的搭建(一行命令即可)
这个开发平台非常适合进行图形界面和可视化应用的开发。首先,我们需要安装Eclipse CDT(C/C++ Development Tooling)作为开发平台的基础。
基于Qt开发平台开发的电脑端飞机大战游戏
【Qt开发平台简介】Qt是一个跨平台的C++图形用户界面应用程序开发框架,由挪威的Trolltech公司(现已被Nokia收购)开发。


