需要 Qt 代码块配置方面的帮助!

发布于 2024-09-07 18:23:12 字数 2438 浏览 4 评论 0原文

代码块 8.02。 , win xp SP2 , Qt 4.6

安装Qt SDK后,我安装了QtWorkbench(允许您创建Qt应用程序的codeblocks插件。) http://code.google.com/p/qtworkbench/

我按照该页面的指示工作。我打开了文件夹“dialogs”,并在其中打开了一个新的空代码块项目。另外,在这个文件夹“dialogs”中,我打开了一个新目录“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 个警告

在项目所在的文件夹“dialogs”中,创建了新文件:

complexwizard.pro

Makefile.complexwizard

Makefile.complexwizard.Debug

Makefile.complexwizard.Release

因为我对编程、编译器和其他的事情,这并没有告诉我太多。

因此,我请求根据这些症状有一些建议的人帮助我摆脱停滞状态。 如果您有兴趣,我将添加更多需要的数据

codeblocks 8.02. , win xp SP2 , Qt 4.6

After installing Qt SDK, I installed QtWorkbench (codeblocks plugin that allows you to create Qt applications.) http://code.google.com/p/qtworkbench/.

I worked under instructions from that page. I opened the folder "dialogs" and in it I opened a new empty codeblocks project. Also in this folder "dialogs" I opened a new directory "complexwizard". In complexwizard is simple 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();
}

Then I added, "main.cpp" in a blank project and all configured according to the instructions from that page.

When I started to compile the program, compiler always says:

* It seems that this project has not been built yet. Do you want to buid it now? *

I press yes an got this message :

Process terminated with status 2 (0 minutes, 0 seconds)
0 errors, 0 warnings

In the folder "dialogs" where is a project, new files are created:

complexwizard.pro

Makefile.complexwizard

Makefile.complexwizard.Debug

Makefile.complexwizard.Release

Since I am relatively new to the world of programming, compiler and other things, this does not tell me much.

Therefore, I ask someone who has some suggestion on the basis of these symptoms to help me remove it from standstill.
If you're interested, I'll add more data that will need

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深爱不及久伴 2024-09-14 18:23:12

我是 QtWorkbench 的作者,不久前我已经停止支持它了。我很确定它现在已经过时了。我真的认为 Qt 新用户应该使用 QtCreator 这个“官方”Qt IDE,以获得开箱即用的最佳支持。 QtWorkbench 仍在 Google 代码中,以防有人想要开始开发它。

I 'm the author of QtWorkbench and I have stopped supporting it some time ago. I 'm pretty sure it's outdated by now. I really think that new Qt users should go with QtCreator the "official" Qt IDE to get the best support out of the box. QtWorkbench is still in Google Code in case any one wants to pick up developing it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文