Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Qt5 in VS2012 Getting Started code gives me undefined class errors
Forum Updated to NodeBB v4.3 + New Features

Qt5 in VS2012 Getting Started code gives me undefined class errors

Scheduled Pinned Locked Moved Installation and Deployment
7 Posts 5 Posters 6.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kvanberendonck
    wrote on 26 Dec 2012, 02:35 last edited by
    #1

    I built Qt5 and added the .lib files and header files from qtbase/include and qtbase/lib into my project in VS2012 Update 1. I'm not using the Qt plugin for now, but that shouldn't matter.

    The code I'm using is this:
    @#include <QtGui>

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    QWidget window;
    window.resize(320, 240);
    window.show();
    window.setWindowTitle(
    QApplication::translate("toplevel", "Top-level widget"));
    return app.exec();
    }@
    QtGui is included fine. All the classes show up w/ intellisense.

    @The errors I get, however, look like this:
    1>------ Build started: Project: QtTest, Configuration: Debug Win32 ------
    1> Main.cpp
    1>c:\users\kyle\documents\visual studio 2012\projects\qttest\qttest\main.cpp(5): error C2079: 'app' uses undefined class 'QApplication'
    1>c:\users\kyle\documents\visual studio 2012\projects\qttest\qttest\main.cpp(5): error C2078: too many initializers
    1>c:\users\kyle\documents\visual studio 2012\projects\qttest\qttest\main.cpp(5): error C2440: 'initializing' : cannot convert from 'char *[]' to 'int'
    1> There is no context in which this conversion is possible
    1>c:\users\kyle\documents\visual studio 2012\projects\qttest\qttest\main.cpp(6): error C2079: 'window' uses undefined class 'QWidget'
    ... more@

    Any ideas?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JKSH
      Moderators
      wrote on 26 Dec 2012, 05:38 last edited by
      #2

      -Have you added `#include <QApplication>'?-

      Edit: Sorry, didn't read properly... my bad. No ideas, sorry

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rubikon
        wrote on 27 Dec 2012, 12:03 last edited by
        #3

        Same Problem here :-(

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kvanberendonck
          wrote on 27 Dec 2012, 12:43 last edited by
          #4

          Yeah, still looking for a solution :|

          1 Reply Last reply
          0
          • A Offline
            A Offline
            apbyte
            wrote on 22 Jan 2013, 22:47 last edited by
            #5

            Same problem with VS2010 :/ AND NO ANSWERS

            1 Reply Last reply
            0
            • S Offline
              S Offline
              steno
              wrote on 22 Jan 2013, 23:22 last edited by
              #6

              This makes sense, QApplication isn't in QtGui.

              [quote author="JKSH" date="1356500304"]-Have you added `#include <QApplication>'?-

              Edit: Sorry, didn't read properly... my bad. No ideas, sorry[/quote]

              1 Reply Last reply
              0
              • A Offline
                A Offline
                apbyte
                wrote on 22 Jan 2013, 23:51 last edited by
                #7

                I got lucky.

                This helped me:
                @#include <QtWidgets/QApplication>@

                In .pro file added these:
                @QT += core gui widgets@

                This still did not worked, so next was to delete everything else except my main.cpp and *.pro file as well as deleting previously compiled output directory. After deleting everything my next build worked :-)

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved