代码块 8.02. , 赢 xp SP2 , Qt 4.6
安装 Qt SDK 后,我安装了 QtWorkbench(允许您创建 Qt 应用程序的代码块插件。)http://code.google.com/p/qtworkbench/。
我在该页面的指示下工作。我打开了文件夹“对话框”,并在其中打开了一个新的空代码块项目。同样在这个文件夹“对话框”中,我打开了一个新目录“complexwizard”。在 complexwizard 中是简单的 main.cpp :
#include <QWidget>
#include <QApplication>
#include <QPushButton>
#include <QLabel>
#include <QDesktopWidget>
class Communicate : public QWidget
{
Q_OBJECT
public:
Communicate(QWidget *parent = 0);
private slots:
void OnPlus();
void OnMinus();
private:
QLabel *label;
};
void center(QWidget *widget, int w, int h)
{
int x, y;
int screenWidth;
int screenHeight;
QDesktopWidget *desktop = QApplication::desktop();
screenWidth = desktop->width();
screenHeight = desktop->height();
x = (screenWidth - w) / 2;
y = (screenHeight - h) / 2;
widget->move( x, y );
}
Communicate::Communicate(QWidget *parent)
: QWidget(parent)
{
int WIDTH = 350;
int HEIGHT = 190;
resize(WIDTH, HEIGHT);
QPushButton *plus = new QPushButton("+", this);
plus->setGeometry(50, 40, 75, 30);
QPushButton *minus = new QPushButton("-", this);
minus->setGeometry(50, 100, 75, 30);
label = new QLabel("0", this);
label->setGeometry(190, 80, 20, 30);
connect(plus, SIGNAL(clicked()), this, SLOT(OnPlus()));
connect(minus, SIGNAL(clicked()), this, SLOT(OnMinus()));
center(this, WIDTH, HEIGHT);
}
void Communicate::OnPlus()
{
int val = label->text().toInt();
val++;
label->setText(QString::number(val));
}
void Communicate::OnMinus()
{
int val = label->text().toInt();
val--;
label->setText(QString::number(val));
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Communicate window;
window.setWindowTitle("Communicate");
window.show();
return app.exec();
}
然后我在一个空白项目中添加了“main.cpp”,并根据该页面的说明进行了所有配置。
当我开始编译程序时,编译器总是说:
* 看来这个项目还没有建成。你想现在买吗?*
我按是并收到此消息:
进程以状态 2 终止(0 分钟,0 秒)0 个错误,0 个警告
在项目所在的文件夹“对话框”中,将创建新文件:
复杂向导.pro
Makefile.complexwizard
Makefile.complexwizard.Debug
Makefile.complexwizard.Release
由于我对编程、编译器和其他事物的世界还比较陌生,所以这并不能告诉我太多。
因此,我请根据这些症状有一些建议的人帮助我将其从静止状态中移除。如果你有兴趣,我会添加更多需要的数据