Results 1 to 9 of 9

Thread: Code::Blocks and QT4

  1. #1
    Join Date
    Nov 2006
    Beans
    153

    Code::Blocks and QT4

    Here's a little walkthrough to using QT4 with Code:Blocks.

    What this assumes:

    1. You have QT4 and Code::Bocks installed.
    2. You know how to use qmake.
    Step 1:
    You're going to need a special little tool known as qt-prebuild (see attachment). Build it and place somewhere easily accessible.

    Step 2:
    Here is the setup:








    Step 3:
    Compile.

    Remember to copy your setup over to Release as well and have fun coding!
    Attached Files Attached Files

  2. #2
    Join Date
    Apr 2008
    Beans
    2

    Re: Code::Blocks and QT4

    I manage to get the file but the pictures are not available anymore. Is there any way you can post them again. Thanks

  3. #3
    Join Date
    Jul 2008
    Beans
    11

    Re: Code::Blocks and QT4

    I had the same problem. went through various forums and found this answer. The wizard now works and generates a compilable project. The paths are given in the picture.

    I installed the following packages using the synaptic package manager

    libqt4-core libqt4-gui libqt4-debug libqt4-dev qt4-designer qt4-dev-tools qt4-doc

    should work
    Attached Images Attached Images

  4. #4
    Join Date
    Aug 2008
    Location
    Montreal
    Beans
    4

    Re: Code::Blocks and QT4

    I set my Global Variables the same as nilankaraja did, as per the screenshot. Unfortunately I get the following errors:
    Code:
    /home/ronnie/Programming Tests/QT TEST Thing/main.cpp|1|error: QApplication: No such file or directory|
    /home/ronnie/Programming Tests/QT TEST Thing/main.cpp|2|error: QFont: No such file or directory|
    /home/ronnie/Programming Tests/QT TEST Thing/main.cpp|3|error: QPushButton: No such file or directory|
    /home/ronnie/Programming Tests/QT TEST Thing/main.cpp||In function ‘int main(int, char**)’:|
    /home/ronnie/Programming Tests/QT TEST Thing/main.cpp|7|error: ‘QApplication’ was not declared in this scope|
    /home/ronnie/Programming Tests/QT TEST Thing/main.cpp|7|error: expected `;' before ‘app’|
    /home/ronnie/Programming Tests/QT TEST Thing/main.cpp|9|error: ‘QPushButton’ was not declared in this scope|
    /home/ronnie/Programming Tests/QT TEST Thing/main.cpp|9|error: expected `;' before ‘quit’|
    /home/ronnie/Programming Tests/QT TEST Thing/main.cpp|11|error: ‘quit’ was not declared in this scope|
    /home/ronnie/Programming Tests/QT TEST Thing/main.cpp|12|error: ‘QFont’ has not been declared|
    /home/ronnie/Programming Tests/QT TEST Thing/main.cpp|12|error: ‘QFont’ was not declared in this scope|
    /home/ronnie/Programming Tests/QT TEST Thing/main.cpp|14|error: ‘QObject’ has not been declared|
    /home/ronnie/Programming Tests/QT TEST Thing/main.cpp|14|error: ‘clicked’ was not declared in this scope|
    /home/ronnie/Programming Tests/QT TEST Thing/main.cpp|14|error: ‘SIGNAL’ was not declared in this scope|
    /home/ronnie/Programming Tests/QT TEST Thing/main.cpp|14|error: ‘app’ was not declared in this scope|
    /home/ronnie/Programming Tests/QT TEST Thing/main.cpp|14|error: ‘SLOT’ was not declared in this scope|
    ||=== Build finished: 15 errors, 0 warnings ===|

    I checked /usr/inclue/qt4 and all the headers are there in their given directories. Like qapplication.h is under /usr/inclue/qt4/qt. I changed it to that direct path to test, but that gave the same error. I've done the silly things, like test the includes with lowercase, with .h at the end, by trying to include the full path etc.

    This is the code I'm trying to compile:
    Code:
    #include <QApplication>
    #include <QFont>
    #include <QPushButton>
    
    int main(int argc, char* argv[])
    {
        QApplication app(argc, argv);
    
        QPushButton quit("Quit");
    
        quit.resize(75, 30);
        quit.setFont(QFont("Times", 18, QFont::Bold));
    
        QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));
    
        quit.show();
    
        return app.exec();
    }
    Thanks in advance for any help


    *As per http://wiki.codeblocks.org/index.php...iler_variables the Base should be /usr, the lib should be /usr/lib and the include should be /usr/include. Not that it works, haha.
    Last edited by rquin; August 25th, 2008 at 07:32 PM.

  5. #5
    Join Date
    Aug 2007
    Beans
    33

    Re: Code::Blocks and QT4

    I'm not sure b/c i'm at work. But do you have to specify your project to link to the correct objects? I am not sure if that's what nilankaraja is saying, but on my windows version here @ work, I have to go into project build options and specify which libraries I want to link with it -- in your case the qt library.

    Project Properties | build options | linker settings (tab)


    --not sure if this is what you do on the linux distro as i'm using the windows version

  6. #6
    Join Date
    Aug 2008
    Location
    Montreal
    Beans
    4

    Re: Code::Blocks and QT4

    I reviewed the build options and the global variables (See Screens). Thanks for looking at this

    Unfortunately I still get the error message
    Attached Images Attached Images
    Last edited by rquin; August 26th, 2008 at 04:10 AM. Reason: Wasn't clear that there was still an issue.

  7. #7
    Join Date
    Aug 2008
    Beans
    1

    Re: Code::Blocks and QT4

    You can select item.

    1. select "project" -> "build options" for add incldue path.

    2. select "search directories" -> "compiler"

    3. select "add" to add include file.

    e.g.
    /usr/include
    /usr/include/qt4
    /usr/include/qt4/Qt
    /usr/include/qt4/QtCore
    /usr/include/qt4/QtGui
    etc...

    Then Code:Blocks will find qt incldue file.

  8. #8
    Join Date
    Oct 2006
    Location
    Australia
    Beans
    224
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Code::Blocks and QT4

    Quote Originally Posted by shulong View Post
    You can select item.

    1. select "project" -> "build options" for add incldue path.

    2. select "search directories" -> "compiler"

    3. select "add" to add include file.

    e.g.
    /usr/include
    /usr/include/qt4
    /usr/include/qt4/Qt
    /usr/include/qt4/QtCore
    /usr/include/qt4/QtGui
    etc...

    Then Code:Blocks will find qt incldue file.
    Thanks a lot. It works, however I found your instructions a bit hard to follow / unclear / confusing.


    1. You should be in a project (just to make it clear for newbies)
    2. Right click on the project (The thing right under workspaces)
    3. Choose Properties
    4. Under "Project settings" (first tab and probably selected by default) click on "Project's build options".
    5. Click on "Search directories"
    6. Click on "Add" and put in "/usr/include/qt4" (or wherever the installation of Qt is - by default on Ubuntu it is put here.)

    (Attached image helps with instructions)

    If the program will still not compile, and is producing errors (along the same line) then you may need to add the extra directories
    Quote Originally Posted by shulong View Post
    e.g.
    /usr/include
    /usr/include/qt4
    /usr/include/qt4/Qt
    /usr/include/qt4/QtCore
    /usr/include/qt4/QtGui
    etc....
    The button next to the filename you add is the browse. use that to find the other folders by first putting in "/usr/include/qt4", then click on the button. This will show you some of the folders mentioned above, plus more.
    Attached Images Attached Images
    Linux User|Ubuntu User|My Website|Computer tips
    1) Core 2 Quad|Geforce 8600GT|EVGA nForce 650i Ultra Mainboard|9.10 - 64-bit |||| 2) Eeepc 900|Ubuntu 9.10 - 32-bit |||| 3) iBook 17" G4 | Ubuntu 9.10 - 32-bit
    Proudly a Christian.

  9. #9
    Join Date
    May 2009
    Location
    Germany
    Beans
    13
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Code::Blocks and QT4

    None of the proposed solutions actually worked for me (Lucid 10.04 and Code::Blocks from the Lucid repos). The following solution, however, works great!

    http://www.amazing-tutorials.com/qt/...th-code-block/

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •