I have installed Qt Creator with the msvc2017_64 binary. I also installed the Qt add-in for VS2017. I can create a QtGuiApplication without any problems, but when i try to compile it, many errors appear. I listed them here, on pastebin, because I cannot add this many characters to Stackoverflow. I'm sorry for that.
Do I need any essential packages for this? I installed C++ for VS2017 ofc. I also included the QtPath in the Qt VS Tools menu.
I did not edit the files since project creation and compiling fails due to errors.
EDIT: This problem is solved here. But not only the Errors form Pastebin exist, also the one following in the QtGuiApplication.h
QtGuiApplication.h: (Errors marked as comments)
#pragma once
#include <QtWidgets/QMainWindow>
#include "ui_QtGuiApplication1.h" //This could not be found
class QtGuiApplication1 : public QMainWindow
{
Q_OBJECT
public:
QtGuiApplication1(QWidget *parent = Q_NULLPTR);
private:
Ui::QtGuiApplication1Class ui; //Ui namespace does not exist
};
QtApplication.cpp:
#include "stdafx.h"
#include "QtGuiApplication1.h"
QtGuiApplication1::QtGuiApplication1(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
}
main.cpp:
#include "stdafx.h"
#include "QtGuiApplication1.h"
#include <QtWidgets/QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QtGuiApplication1 w;
w.show();
return a.exec();
}
I solved this problem myself!
The Qt add-in creates the Project with the Windowns 8.1 SDK, you need to retarget it to the Win 10 SDK to get the compile Errors from the QtGuiApplication.h away. Even if the 8.1 SDK is installed. Seems like a bug.
The solution was quite simple to me, just unload and then reload the solution from Solution Explorer!
This will clear all c++ compiler errors! Don't know why ...
Related
I'm trying to run a simple template in release mode on Visual Studio with the Qt extension. So far I've always been running projects in debug mode (never had trouble). Recently, I started with a browser application using webengine its widgets, but it's very slow on debug mode, so. I wanted to make sure it's possible to run with higher performance (on release mode), before continuing.
I was surprised, because the application throws 4 error message pop-ups after each other after trying to run it:
The procedure entry point ?endl#QTextStreamFunctions##YAAEAVQTextStream##AEAV2##Z could not be located in the dynamic link library C:\Qt\5.14.1\msvc2017_64\bin\Qt5WebChannel.dll.
The procedure entry point ?argToQString#QQtPrivate...QString...QStringView... could not be located in the dynamic link library C:\Qt\5.14.1\msvc2017_64\bin\Qt5WebChannel.dll.
Two more similar ones for QDebug and QRhiDepthStencilClearValue.
So instead, I tried to compile a simple project (the direct QtWidgetsApplication template) and it gave me this:
This application failed to start because no Qt Platform plugin could be initialized. Reinstalling the application may fix this problem.
I've been looking for a solution for quite some time now, but I didn't find a clear answer.
My directory: C:\Qt\5.14.1\msvc2017_64
My template code:
#include "QtWidgetsApplication2.h"
#include <QtWidgets/QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QtWidgetsApplication2 w;
w.show();
return a.exec();
}
#pragma once
#include <QtWidgets/QMainWindow>
#include "ui_QtWidgetsApplication2.h"
class QtWidgetsApplication2 : public QMainWindow
{
Q_OBJECT
public:
QtWidgetsApplication2(QWidget *parent = Q_NULLPTR);
private:
Ui::QtWidgetsApplication2Class ui;
};
#include "QtWidgetsApplication2.h"
QtWidgetsApplication2::QtWidgetsApplication2(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
}
I have no clue of how to fix this problem. Could you please help me out? Thanks in advance!
See if this helps.
Are you trying to start the program by double clicking the .exe ?
I tried to reproduce it:
build a simple project in release mode
run windeployqt ... and delete the generated folder ./platforms
double click on .exe to run it.
and prompts the error message you got.
I am programming with Qt Creator on a Mac (High Sierra 10.13.4). My projects seem to spontaneously break after a few days of work.
The linker error given is: "symbol(s) not found for architecture x86_64".
There is nothing wrong with the code - I open, run, close, and reopen projects and they are suddenly broken. I have also tested this with Qt's provided examples, to the same effect. I can copy-paste the code to a new project and compile it with no problem, but it will eventually do the same thing again.
I have attempted deleting the whole debug output folder of the project to give it a fresh start, but it did not make a difference. Same error.
Has anyone had this issue with QtCreator before? Is there a solution?
I have looked up a lot of very similar questions on here, but they all seem to be errors with the code. Just in case it's the same with me, this is all my code:
//main.cpp
#include "display.h"
#include "frame.h"
#include <QApplication>
int main(int argc, char * argv[])
{
QApplication a(argc, argv);
Display w;
w.show();
return a.exec();
}
Display.h & Frame.h are auto-generated.
//display.cpp
#include "display.h"
#include "ui_display.h"
#include "frame.h"
Display::Display(QWidget *parent) : QMainWindow(parent), ui(new Ui::Display)
{
ui->setupUi(this);
QWidget * f = new Frame(this);
setCentralWidget(f);
}
Display::~Display()
{
delete ui;
}
Frame.cpp last:
#include "frame.h"
#include "ui_frame.h"
Frame::Frame(QWidget *parent) : QFrame(parent), ui(new Ui::Frame)
{
ui->setupUi(this);
}
Frame::~Frame()
{
delete ui;
}
It is not that the linker error is as given. There's way more to it, and you're not including the meat of the message that actually carries meaningful information allowing to debug this issue. Your problem is possibly with the project becoming internally binary-incompatible, and qmake build system not catching onto it. The issue has nothing to do with Qt Creator. The build is done by qmake and make. You'll see those problems if you build from the command line - which I highly advise you to do.
Assuming the sources are in /Users/mycaptain/src/myproject, and that you're using Qt from macports, proceed as follows in terminal:
$ mkdir ~/src/build-myproject
$ cd ~/src/build-myproject
$ /opt/local/libexec/qt5/bin/qmake ../myproject
$ make
I compiled Qt 4.8.1 with these instructions:
http://www.holoborodko.com/pavel/2011/02/01/how-to-compile-qt-4-7-with-visual-studio-2010/
for my system (Visual Studio 2010, x64). The compilation worked and everything seemed Ok.
While compiling there is a lot of output, but it's very fast and therefore I can't read it so i suppose that shouldn't be a problem.
After I compiled succesfully my current project I got an unhandled runtime exception. After a while I discovered that it comes from the QMdiArea::addSubwindow function, which seems to throw the exception (I'm not able to catch it with overriden notify function though). So I searched for an example project to see if it's my code or something else. I found this example here:
http://www.codeprogress.com/cpp/libraries/qt/qMdiAreaAddSubWindow.php
And it works fine in 32bit mode as well as debug mode of x64, but again at the
QMdiArea::addSubwindow function there is an unhandled exception. Has anyone an idea what's wrong or had the same problem?
Currently I'm recompiling Qt to get the debug information again (i cleaned it beforehand).
But maybe someone had the same problem and a solution for me.
//Update:
The code is here (the exact same as in the link)
#include <QApplication>
#include <QMainWindow>
#include <QMdiArea>
#include <QMdiSubWindow>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QMainWindow window;
window.setFixedSize(800,600);
window.setWindowTitle(QString::fromUtf8("My QMdiWindow"));
QMdiArea* area = new QMdiArea();
area->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
//Create QMdiSubWindow
QMdiSubWindow* subWindow = new QMdiSubWindow();
subWindow->setFixedSize(200,100);
//Add subWindow to Main QMdiWindow here
area->addSubWindow(subWindow);
window.setCentralWidget(area);
window.show();
return app.exec();
}
//Update2:
I opened another discussion here.
Ok, I found the problem. It is a bug in the MSVC++ compiler. Installing the service pack and recompiling Qt again helps.
I'm trying to create a simple GUI application (so far) in Qt with C++ using the MinGW compiler. However, the compiler is informing me that I have a multiple definition of 'WiimoteScouter::WiimoteScouter(QWidget*)' on line 4 of wiimotescouter.cpp. I am using a check to make sure the header isn't included multiple times, but apparently it's not working, and I'm not sure why.
Here's the header file:
#ifndef WIIMOTESCOUTER_H
#define WIIMOTESCOUTER_H
#include <QWidget>
class QLabel;
class QLineEdit;
class QTextEdit;
class WiimoteScouter : public QWidget
{
Q_OBJECT
public:
WiimoteScouter(QWidget *parent = 0);
private:
QLineEdit *eventLine;
};
#endif // WIIMOTESCOUTER_H
And here's the cpp file:
#include <QtGui>
#include "wiimotescouter.h"
WiimoteScouter::WiimoteScouter(QWidget *parent) :
QWidget(parent)
{
QLabel *eventLabel = new QLabel(tr("Event:"));
eventLine = new QLineEdit;
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(eventLabel, 0, 0);
mainLayout->addWidget(eventLine, 0, 1);
setLayout(mainLayout);
setWindowTitle(tr("Wiimote Alliance Scouter"));
}
Lastly, the main.cpp:
#include <QtGui>
#include "wiimotescouter.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
WiimoteScouter wiimoteScouter;
wiimoteScouter.show();
return app.exec();
}
I've seen this happen before when a source file got duplicated in the project (.pro or .pri) file. Check all of the "SOURCES =" and "SOURCES +=" lines in your project file and make sure the cpp file is not in there more than once.
I don't use MinGW but this sounds like a linker error rather than a compiler error. If this is the case then you should check that the .CPP file is not added to the project twice. I also noticed that the extension is "php", this is very unusual as it should be "cpp".
Answer just for reference:
I was including
#include myclass.cpp
instead of
#include myclass.h
This can also happen if you have two .ui files with the same name in different folders. Their corresponding headers are built in the same directory, resulting in one being overwritten. At least that was my problem.
I got this error message when I had my slot declarations listed listed under the signals heading in the header file, rather than the slots one. Another thing for anyone experiencing this error message to check for.
Cut and paste solved the problem and a need to check next time I create Slots manually.
For me it was due to Qt's compilation model in Windows using MinGW.
My code compiled perfectly fine for Linux, but for Windows the linker errors were happening for following files:
Message.cpp
Util.cpp
At first, in the .pro file, I couldn't find any similar file names. Then observing keenly I figured out that, the external google protobuf library, which I was compiling along, had some library files inside its folder named as:
message.cc
util.cc
The cases and the extensions were different, but somehow it created mess in the Qt compilation. I just added an underscore to those library files and the things worked fine.
In my case this was caused by having the function declared globally in a header file.
So far I have worked in the console and a few days ago decided to try the QT GUI.
I downloaded the QT SDK , install it, adjust the location of QT and
set up the PATH Environment Variable -> per the instructions on the site.
I opened a new Qt4 project in Code:: Blocks-in and it seemed that everything was OK.
There is by default an example:
#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();
}
Started it an it was all OK.
After that I went to a tutorial on the official site and there is a final example.
Some kind of simple game.I have done copy-paste of all .h and .cpp files and then put
them in current project to see how it works but then problems arise.
Code::Blocks does not recognize some classes.
For example :: #include QTimer : No such file or directory
#include QRect : No such file or directory
I uninstall QT and re-installed and configured everything again but the problem does not go out.
These classes are not working nor in the default example ::
#include <QApplication>
#include <QFont>
#include <QPushButton>
#include <QTimer> does not have real purpose , just for illustration
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();
}
ba\107\main.cpp|4|QTimer: No such file or directory|
||=== Build finished: 1 errors, 0 warnings ===|
I dont now how much classes don work properly , this is just some of them.
Not to reveal hot water for days on google looking for a solution, maybe for some of you
, this is a bizarrely easy problem.
Thanks
You need to either spend time monkeying with the default include search path, or else just provide a more explicit path the header you want to include. I was able to reproduce your problem with Code::Blocks 10.05 (with bundled gcc) on Windows XP/32 and a previously installed Qt 4.6. Here is the slightly changed version of your code that I was able to build without any problem:
#include <QApplication>
#include <QFont>
#include <QPushButton>
#include <QtCore/QTimer>
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();
}
Take a look in your Qt install directory. You'll be able to see the include directory, and where all the headers are within it if you run into this problem with any other headers. It looks like the Code::Blocks projects sets up the QtGui directory as an include search path by default, which is why you didn't need to explicitly mention it for including QPushButton and whatnot.
Code::Blocks is only an IDE not a Compiler/Linker toolchain, so it is not Code::blocks that cant find the files, you have simply not configured your project to use them.
"No such file or directory" is a pre-processor error message; you still have to tell the compiler where to find your third-party header files. Moreover when it comes to linking, you will need to tell the linker where to find the libraries.
Whenever you have an #include <blah> (with angle bracktes <>) the compiler looks in the default include path. You need to put the Qt include directory into the include path for your project. I'm not sure how this is done in Code::Blocks. It's probably somewhere in the project settings.