读书人

QT开发平台,该怎么解决

发布时间: 2013-01-21 10:15:38 作者: rapoo

QT开发平台
我在ubuntu下面安装了一个QT开发工具,但是后面进入QT Creator后,直接运行example都不行,我主要目的是
在源文件有的情况下,可以运行出一个出来,这是一个的猜数字游戏(网上下载的)
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



引用:
引用:三个文件放在一个文件夹下面.
qmake -project
生成工程文件
然后
qmake生成Makefile
make编译
我安装了QT,如下

但是我的安装目录下的bin中

没有qmake-project命令,只有qmake呀。谢谢你的帮助

读书人网 >UNIXLINUX

热点推荐