Author Topic: Using Qt  (Read 11373 times)

Offline bfr

  • Multiple posting newcomer
  • *
  • Posts: 17
Using Qt
« on: May 29, 2007, 03:07:22 am »
Has anybody here gotten Qt to fully work with Code::Blocks? Even with the QtWorkBench plugin, I haven't gotten a program to succesfully build and run.  I have gotten code to work that doesn't require the Meta Object Compiler (MOC) to be run, but if I use something like Q_OBJECT that requires the Meta Object Compiler, it doesn't work.  Right now, I'm getting:

Code: [Select]
/usr/bin/sh: -c: line 2: syntax error: unexpected end of file
mingw32-make.exe: *** [Release\Makefile] Error 258
Process terminated with status 2 (0 minutes, 14 seconds)
0 errors, 0 warnings

When trying to compile the default code that the Qt template in Code::Bocks generates. 

Oh, and by the way, I've tried Qt 4.2.3 and Qt 3 Release Candidate 1, and niether have worked.

kenneth.balslev

  • Guest
Re: Using Qt
« Reply #1 on: May 29, 2007, 08:50:54 am »
Yeah, I got it to work..

You may want to take a look at this thread:

http://forums.codeblocks.org/index.php/topic,2253.0.html

There are some odd issues with Qt on C::B. For example, you have to create a Debug and Release folder in the project folder - not under the Bin folder (which is the default). Additionally, once I have built my Qt projects, I have been unsuccesful in re-building them (I get a strange error message). Only when I delete the contents of the Debug and Release folders, I can succesfully build my Qt application again. I don't know if anybody else had the same experience?

Offline yop

  • Regular
  • ***
  • Posts: 387
Re: Using Qt
« Reply #2 on: May 29, 2007, 11:51:43 am »
I 've seen all these issues and I 'm working towards them in QtWorkbench. I have already finished a first .pro parser version, the .pro generator and I am fixing the project options dialog and the build sytem (the later will be much simpler than before). The configuration dialog is also ready. These sources are not in the "official" svn as they break the plugin, but will be in the next few days if my day job continues to run smoothly.
The main thing that we have to address is to achieve some kind of compatibility between the C::B build system and the way qmake generates Makefiles. The solution I came up with is to produce different .pro files in the top level project directory for each target. The obvious solution of SUBDIR entries is doomed by default unfortunatelly because C::B projects don't prerequisite that a respective folder will exist for each target while qmake expects that. Also since the qmake generated Makefiles dive into subdirs during builds you get broken debugger functionality. I could name numerous more little inconviniences while trying to use Qt with C::B and that's why I started with the plugin in the first place. The main thing was that I knew the weaknesses of the plugin and I could/can adopt my projects to be "friendly" with it. This is not the case with the user that just wants the plugin to work out of the box without having to know it's internals. These are the issues I am working on and the results are encouraging. Of course untill I get it to be stable there will still be little anoyances, if you can all bare with them and provide some feedback it would be nice. Untill then the following post describes how to set up QtWorkbench projects as it is now:
http://forums.codeblocks.org/index.php/topic,2253.msg45295.html#msg45295
Life would be so much easier if we could just look at the source code.

Offline bfr

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: Using Qt
« Reply #3 on: May 31, 2007, 12:56:01 am »
OK, thanks.  After creating Release and Debug folders in the project directory, though and compiling with the QtWorkBench plugin, it still didn't work (I got the same error as in my first post).  I guess I'll just wait a few days for the next release of the QtWorkBench plugin, and see if that works.

Is there anything in particular I have to do with the /obj directory and what is in it?

EDIT:  I kind of got it to work.  I still get:

Code: [Select]
objReleasemain.o:main.cpp:(.text+0x68):: undefined reference to `vtable for MainWindow'
objReleasemain.o:main.cpp:(.text+0x6f):: undefined reference to `vtable for MainWindow'
objReleasemain.o:main.cpp:(.text+0xdf):: undefined reference to `MainWindow::staticMetaObject'
objReleasemain.o:main.cpp:(.text+0x17f):: undefined reference to `MainWindow::staticMetaObject'
objReleasemain.o:main.cpp:(.text+0x3c8):: undefined reference to `vtable for MainWindow'
objReleasemain.o:main.cpp:(.text+0x3cf):: undefined reference to `vtable for MainWindow'
objReleasemain.o:main.cpp:(.text+0x444):: undefined reference to `MainWindow::staticMetaObject'
objReleasemain.o:main.cpp:(.text+0x4ec):: undefined reference to `MainWindow::staticMetaObject'
objReleasemain.o:main.cpp:(.text+0x77e):: undefined reference to `vtable for MainWindow'
objReleasemain.o:main.cpp:(.text+0x785):: undefined reference to `vtable for MainWindow'
objReleasemain.o:main.cpp:(.text+0x7e1):: undefined reference to `vtable for MainWindow'
objReleasemain.o:main.cpp:(.text+0x7f5):: undefined reference to `vtable for MainWindow'
:: === Build finished: 12 errors, 0 warnings ===

Whenever I use Q_OBJECT, I think.  My code is at http://rafb.net/p/RJk0f872.html .
« Last Edit: May 31, 2007, 01:03:37 am by bfr »

Offline yop

  • Regular
  • ***
  • Posts: 387
Re: Using Qt
« Reply #4 on: May 31, 2007, 04:15:54 pm »
Remove your Makefiles. You have to rerun qmake after making sure that everything that is derived from QObject has the Q_OBJECT macro in the class header. This is a classical error of not generated (and compiled and linked) moc source files.
Life would be so much easier if we could just look at the source code.

Offline bfr

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: Using Qt
« Reply #5 on: June 03, 2007, 06:23:12 am »
Thanks for your help.  I did what kenneth.balslev said to do, along with what you (yop) said to do, but now I'm getting:

Code: [Select]
/usr/bin/sh: -c: line 2: syntax error: unexpected end of file
mingw32-make.exe: *** [Release\Makefile] Error 258
Process terminated with status 2 (0 minutes, 0 seconds)
0 errors, 0 warnings

Will this be fixed in a future release of the QtWorkBench plugin?  If so, how long do you estimate it will take for this future version to be released?
 

Offline yop

  • Regular
  • ***
  • Posts: 387
Re: Using Qt
« Reply #6 on: June 04, 2007, 08:24:47 pm »
I can't tell you if the specific problem will be fixed as I don't know what's causing it. The sources for the (almost rewritten) plugin are in a svn branch. I 'll be in Madrid on a business trip for a week or so, starting on  Wednesday, so I guess that next weekend it will be available.
Life would be so much easier if we could just look at the source code.

Offline bfr

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: Using Qt
« Reply #7 on: June 11, 2007, 08:00:29 pm »
Is http://qtworkbench.googlecode.com/svn/trunk the latest version of the QtWorkBenchpPlugin?  Because Code::Blocks doesn't like it.  It wants a .cbplugin instead of a .cbp.  When I rename the QtWorkBench plugin to hve a .cbplugin extention, Code::Blocks still doesn't accept it.  I have the latest Nightly build of Code::Blocks.

Offline TDragon

  • Lives here!
  • ****
  • Posts: 936
    • Twilight Dragon Media
Re: Using Qt
« Reply #8 on: June 11, 2007, 08:57:08 pm »
Is http://qtworkbench.googlecode.com/svn/trunk the latest version of the QtWorkBenchpPlugin?
That's the source code; you would need to compile it yourself along with wxWidgets and Code::Blocks.
http://tdm-gcc.tdragon.net/ - TDM-GCC compiler suite for Windows (GCC 5.1.0 2015-06-28, 32/64-bit, no extra DLLs)

Offline bfr

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: Using Qt
« Reply #9 on: June 11, 2007, 10:00:43 pm »
I'm getting some errors:

Code: [Select]
:: === QtWorkbench, default ===
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtworkbench.cpp:9: sdk.h: No such file or directory
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtworkbench.cpp:10: annoyingdialog.h: No such file or directory
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtworkbench.h:19: cbplugin.h: No such file or directory
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtworkbench.h:22: error: expected class-name before '{' token
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtworkbench.h:58: error: ISO C++ forbids declaration of `cbConfigurationPanel' with no type
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtworkbench.h:58: error: `cbConfigurationPanel' declared as a `virtual' field
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtworkbench.h:58: error: expected `;' before '*' token
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtworkbench.h:67: error: ISO C++ forbids declaration of `cbConfigurationPanel' with no type
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtworkbench.h:67: error: `cbConfigurationPanel' declared as a `virtual' field
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtworkbench.h:67: error: expected `;' before '*' token
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtworkbench.h:79: error: expected `;' before "virtual"
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtworkbench.h:96: error: expected `,' or `...' before "type"
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtworkbench.h:96: error: ISO C++ forbids declaration of `ModuleType' with no type
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtworkbench.h:136: error: `CodeBlocksEvent' has not been declared
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtworkbench.h:136: error: ISO C++ forbids declaration of `event' with no type
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtworkbench.h:140: error: ISO C++ forbids declaration of `cbProject' with no type
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtworkbench.h:140: error: expected `;' before '*' token
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtworkbench.h:51: error: `cgContribPlugin' was not declared in this scope
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtworkbench.h:51: warning: unused variable 'cgContribPlugin'
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:12: settings.h: No such file or directory
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:13: cbproject.h: No such file or directory
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:14: compiler.h: No such file or directory
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: expected initializer before '*' token
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: `_wxArrayTargets_Array' was not declared in this scope
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: typedef `CMPFUNC_wxArrayTargets_Array' is initialized (use __typeof__ instead)
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: `_wxArrayTargets_Array' was not declared in this scope
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: `pItem1' was not declared in this scope
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: `_wxArrayTargets_Array' was not declared in this scope
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: `pItem2' was not declared in this scope
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: ISO C++ forbids declaration of `_wxArrayTargets_Array' with no type
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: expected `;' before '&' token
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: expected `;' before "_wxArrayTargets_Array"
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: ISO C++ forbids declaration of `_wxArrayTargets_Array' with no type
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: expected `;' before '&' token
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: expected `;' before "_wxArrayTargets_Array"
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: ISO C++ forbids declaration of `_wxArrayTargets_Array' with no type
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: expected `;' before '&' token
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: expected `;' before "int"
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: `_wxArrayTargets_Array' has not been declared
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: ISO C++ forbids declaration of `lItem' with no type
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: `_wxArrayTargets_Array' has not been declared
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: ISO C++ forbids declaration of `lItem' with no type
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: `_wxArrayTargets_Array' has not been declared
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: ISO C++ forbids declaration of `lItem' with no type
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: `_wxArrayTargets_Array' has not been declared
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: ISO C++ forbids declaration of `lItem' with no type
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: `_wxArrayTargets_Array' does not name a type
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: `_wxArrayTargets_Array' does not name a type
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:17: error: `_wxArrayTargets_Array' does not name a type
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:18: error: expected initializer before '*' token
C:\Documents and Settings\Owner\Desktop\QTWB\src\qtwprogenerator.h:18: error: `_wxArrayFiles_Array' was not declared in this scope
:: More errors follow but not being shown.
:: Edit the max errors limit in compiler options...
:: === Build finished: 50 errors, 1 warnings ===

Where do I get sdk.h and cbplugin.h?

EDIT:  I think I have to download the Code::Blocks source...?
« Last Edit: June 11, 2007, 10:18:51 pm by bfr »

Offline TDragon

  • Lives here!
  • ****
  • Posts: 936
    • Twilight Dragon Media
Re: Using Qt
« Reply #10 on: June 12, 2007, 01:31:22 am »
I think I have to download the Code::Blocks source...?
And compile it, I imagine. You'll also need to ensure that the QtWorkbench project can find it, either by global variable or by being in the correct location relative to C::B's source. (Check the build options to see which include path references the C::B sources.)
http://tdm-gcc.tdragon.net/ - TDM-GCC compiler suite for Windows (GCC 5.1.0 2015-06-28, 32/64-bit, no extra DLLs)

WhiteStarLine

  • Guest
Re: Using Qt - all seems fine with the 12 June nightly build
« Reply #11 on: June 13, 2007, 04:32:40 am »
Hi guys,

I migrated from DEV-CPP a few months ago and could not get QT 4.0 to compile with C::B 1.0RC2, no matter what I tried (or Googled). I ended up using C::B not as an IDE but as a C++ editor, then used the Trolltech qmake command line to compile.

Last night I uninstalled C::B 1.0RC2, then downloaded Qt 4.3.0, took the MinGW option and then the 12 June nightly build. On loading C::B for the first time, I selected a new QT project and pointed to C:\Qt\4.3.0 as my QT directory, with the 'bin' and 'lib' directories.

The new QT project wizard loaded main.cpp with the correct QT 4 syntax and it compiled immediately and generated the correct GUI executable. I did nothing other than selected the standard options - no work arounds or modifications.

Thanks team, Code:: Blocks is a wonderful product.

*****************
Post edit: Once I tried any QT code requiring Q_OBJECT, C::B would not compile it, reporting the same error messages others have. I tried QT Workbench and put in every project option but it seems hard coded to an earlier QT version (or, you need to download the C::B source and build it yourself). Eventually I downloaded another IDE, which seems to work perfectly. I'll give C::B another go later with the QT workbench as I appreciate the amount of effort that is going into the project.
« Last Edit: June 15, 2007, 02:34:53 am by WhiteStarLine »

Offline bfr

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: Using Qt
« Reply #12 on: June 13, 2007, 09:26:59 pm »
WhiteStarLine, try using the latest Nightly build of Code::Blocks instead of RC2 for starters.  Then, try the QtWorkbench plugin

And although using these will help, I still haven't gotten it to work.  Oh, and reading some of the previous posts in this topic might be helpful too.   
« Last Edit: June 13, 2007, 09:29:01 pm by bfr »

Offline bfr

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: Using Qt
« Reply #13 on: July 12, 2007, 04:10:43 am »
I've been trying for quite a while to get Qt to fully work.  It works...until I use stuff like Q_OBJECT, which makes me get:

Code: [Select]
obj\Release\mainwindow.o:mainwindow.cpp:(.text+0x164):: undefined reference to `MainWindow::staticMetaObject'
obj\Release\mainwindow.o:mainwindow.cpp:(.text+0x263):: undefined reference to `MainWindow::staticMetaObject'
obj\Release\mainwindow.o:mainwindow.cpp:(.text+0x3c8):: undefined reference to `MainWindow::staticMetaObject'
obj\Release\mainwindow.o:mainwindow.cpp:(.text+0x4e9):: undefined reference to `MainWindow::staticMetaObject'
obj\Release\mainwindow.o:mainwindow.cpp:(.text+0x5f3):: undefined reference to `MainWindow::staticMetaObject'
obj\Release\mainwindow.o:mainwindow.cpp:(.text+0x4ef4):: undefined reference to `vtable for MainWindow'
obj\Release\mainwindow.o:mainwindow.cpp:(.text+0x4efb):: undefined reference to `vtable for MainWindow'
obj\Release\mainwindow.o:mainwindow.cpp:(.text+0x4fd1):: undefined reference to `MainWindow::staticMetaObject'
obj\Release\mainwindow.o:mainwindow.cpp:(.text+0x5241):: undefined reference to `MainWindow::staticMetaObject'
obj\Release\mainwindow.o:mainwindow.cpp:(.text+0x5299):: undefined reference to `MainWindow::staticMetaObject'
obj\Release\mainwindow.o:mainwindow.cpp:(.text+0x5554):: undefined reference to `vtable for MainWindow'
obj\Release\mainwindow.o:mainwindow.cpp:(.text+0x555b):: undefined reference to `vtable for MainWindow'
obj\Release\mainwindow.o:mainwindow.cpp:(.text+0x5631):: undefined reference to `MainWindow::staticMetaObject'
obj\Release\mainwindow.o:mainwindow.cpp:(.text+0x58a1):: undefined reference to `MainWindow::staticMetaObject'
obj\Release\mainwindow.o:mainwindow.cpp:(.text+0x58f9):: undefined reference to `MainWindow::staticMetaObject'
obj\Release\main.o:main.cpp:(.text+0xd9):: undefined reference to `vtable for MainWindow'
obj\Release\main.o:main.cpp:(.text+0xe7):: undefined reference to `vtable for MainWindow'
obj\Release\main.o:main.cpp:(.text+0x15f):: undefined reference to `vtable for MainWindow'
obj\Release\main.o:main.cpp:(.text+0x164):: undefined reference to `vtable for MainWindow'
:: === Build finished: 19 errors, 0 warnings ===

I have the latest version of the QtWorkBench plugin.  I have the June 28th build of Code::Blocks.

WhiteStarLine:  What IDE did you end up getting?

Offline yop

  • Regular
  • ***
  • Posts: 387
Re: Using Qt
« Reply #14 on: July 12, 2007, 09:02:38 am »
Please follow the instructions on installing and using the plugin:
http://code.google.com/p/qtworkbench/wiki/PluginInstallation
http://code.google.com/p/qtworkbench/wiki/PluginUsage

The core of the plugin has been rewritten and it is working like expected in most cases. Previous versions were actually based on hackish code that were useful to me but couldn't stand as a stand alone plugin. The current implementation on the other hand is meant to be the default solution for using Qt in Code::Blocks. What I am doing now is getting feddback from plugin users on defects and on how we can make it better. You can also help by submiting your thoughts in the issue tracker. Besides that I am still refactoring the core of the plugin, working in the flexibility of the parser and I hope that I find the time to prepare a project generation wizard as the creation of QtWorkbench projects requires quite a few steps to start up and prepare. You will not see anything impresive in the next few versions of the plugin regarding new features, but stability and hopefully better user experience through automatic C::B project and target generation.

If although you have followed the steps described in the plugin usage pages you can't get it to work please report your problems here or in the plugin site. Oh, and as a side note you don't have to build the plugin yourself anymore if you 're using MS Windows and a recent C::B nightly build.

« Last Edit: July 12, 2007, 09:06:39 am by yop »
Life would be so much easier if we could just look at the source code.