I created a Qt-GUI-Application, in which I want to embed a QtQuick 2.0 QML file.
For that matter I added QT += quick in the .pro file
this is what my code looks like:
#include <QApplication>
#include <QtCore>
#include <QtQuick>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QQuickViewviewer;
viewer.setSource(QUrl::fromLocalFile("file.qml"));
viewer.show();
return a.exec();
}
But all I get is the following error message as soon as I want to built it:
..\main.cpp:3: Error:C1083: Cannot open include file: 'QtQuick': No such file or directory
How can I solve this?
I'm using Qt 5.1.1 on Windows 7
Edit:
This is how the .pro file looks like
#-------------------------------------------------
#
# Project created by QtCreator 2013-10-15T17:54:42
#
#-------------------------------------------------
QT += core gui \
quick
TARGET = IntegratedPowerSupply
TEMPLATE = app
SOURCES += main.cpp
HEADERS +=
OTHER_FILES += \
../../PowerSupply/PowerSupply/file.qml
Related
I'm trying to create a simple qt application in visual studio, I also made sure to install all qt components.
Code:
#include "QtWidgetsApplication2.h"
#include <QtWidgets/QApplication>
#include <QtDataVisualization/Q3DSurface>
#include <QtDataVisualization/QSurfaceDataProxy>
#include <QtDataVisualization/QHeightMapSurfaceDataProxy>
#include <QtDataVisualization/QSurface3DSeries>
#include <QtWidgets/QSlider>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QtWidgetsApplication2 w;
Q3DSurface* graph = new Q3DSurface();
QWidget* container = QWidget::createWindowContainer(graph);
w.show();
return a.exec();
}
I have already set the correct QT version, and the path to the aditional libraries for the linker(at C:\Qt\6.4.0\msvc2019_64\lib) but somehow i'm still getting an error linker LNK2019. What gives?
EDIT:
my .pro file:
TEMPLATE = app
TARGET = QtWidgetsApplication2
DESTDIR = ../x64/Debug
CONFIG += debug
DEPENDPATH += .
MOC_DIR += .
OBJECTS_DIR += debug
UI_DIR += .
RCC_DIR += .
include(QtWidgetsApplication2.pri)
From the Qt documentation for Q3DSurface here: https://doc.qt.io/qt-6/q3dsurface.html on the qmake line at the top it has qmake: QT += datavisualization the QT += datavisualization part is what you need to add to your .pro file to use the Q3DSurface class. This will setup the linking and any additional include directories.
I am using Qt5. I wrote the following code:
#include <QtGui/QApplication>
#include <Qlabel>
int main(int argc, char *argv[]){
QApplication prog(argc, argv);
Qlabel *label = new Qlabel("gametime!");
label->show();
return prog.exec();
}
the following problem occurs:-
error: QtGui/QApplication: No such file or directory
QApplication is part of the Qt5 Widgets library (not the GUI library, which provides lower-level facilities).
Add QT += widgets to your .pro file, and change
#include <QtGui/QApplication>
to
#include <QtWidgets/QApplication>
(You should be able to reduce to just <QApplication>, as QMake will normally add the necessary include paths based on the libraries specified in the QT variable.)
I try to use openCV in a Qt project. But my release build instantly crash on launch if I link the release libs of openCV. Debug libs allow the programm to start but the application crashes when I try to use openCV functions (it is known that mixing release/debug in openCV causes some crash).
So I made a simple project and it won't even launch. Both release and debug build crashes and using debugger causes a small window saying 'unexpected CDB exit'.
Here are the source.
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = test_openCV
TEMPLATE = app
#flags to generate a .map file
QMAKE_LFLAGS_RELEASE +=/MAP
QMAKE_LFLAGS_RELEASE += /debug
SOURCES += main.cpp\
MainWindow.cpp
HEADERS += MainWindow.h
FORMS += MainWindow.ui
INCLUDEPATH += $$PWD
INCLUDEPATH += "D:/openCV/build/include"
#Switching between handbuild and the build I downloaded have no effect.
#I am sure the path are good. Quadra checked.
#LIBS += -L"D:/openCV/build/x64/vc11/lib"
LIBS += -L"D:/openCV/hand_build/lib/Release"
LIBS += -L"D:/openCV/hand_build/lib/Debug"
#disables the "fopen not secure" warning in openCV.
DEFINES += _CRT_SECURE_NO_WARNINGS
win32:CONFIG(release, debug|release): LIBS += -lopencv_core2413 -lopencv_highgui2413 -lopencv_imgproc2413
else:win32:CONFIG(debug, debug|release): LIBS += -lopencv_core2413d -lopencv_highgui2413d -lopencv_imgproc2413d
main.cpp:
#include "MainWindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
MainWindow.h:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <opencv/cv.h>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
and MainWindow.cpp:
#include "MainWindow.h"
#include "ui_MainWindow.h"
#include "opencv2/core.hpp"
#include "opencv2/highgui.hpp"
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
//Removing this line will causes the program to start normally (guess it won't link the libs if nothing from openCV is used).
cv::Mat image;
}
MainWindow::~MainWindow()
{
delete ui;
}
What I get when launching app:
Starting D:\Colin\build_test_openCV\release\test_openCV.exe...
program suddenly ended
D:\Colin\build_test_openCV\release\test_openCV.exe crashed
I work on Windows 7 / MSCV2012 openGL 64bits / Qt 5.2.1 openGL.
Does anyone see a mistakes I could have made?
I have a similar setup as yours and was getting the exact same problem. The issue was that the path to the corresponding dlls was not defined. These dlls:
opencv_core2411.dll
opencv_highgui2411.dll
opencv_imgproc2411.dll
should be in D:/openCV/hand_build/bin/ (or maybe D:/openCV/hand_build/bin/Release/). Adding another line:
LIBS += -L"D:/openCV/hand_build/bin/Release/"
should work.
I just had a similar issue. The program was crashing because it could not find the appropriate DLL at runtime. Adding the OpenCV directories to my Windows PATH fixed the problem for me.
All items in your build must have been built using the same Visual Studio version, that means:
The Qt install you're using.
OpenCV.
Your code.
Most likely at least one of the above was not built using the same compiler. If OpenCV is linked against Qt, it must have been built against a binary-compatible version of Qt, too.
I have read a lot trying to figure this out. I am using QtCreator on Ubuntu 13.10.
.pro:
#-------------------------------------------------
#
# Project created by QtCreator 2014-03-02T09:50:03
#
#-------------------------------------------------
QT += core gui
QT += webkit
QT += webkit webkitwidgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = AndroidDecompiler
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
MAIN
#include "mainwindow.h"
#include <QApplication>
#include <QtWebKit>
#include <QWebView>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
QWebView view;
view.show();
view.setUrl(QUrl("http://google.com"));
return a.exec();
}
Here is error ':-1: error: cannot find -lsqlite3'
I think it is due to not being able to include webview. Is their any suggestions?
You could install the sqlite3 library as follows:
sudo apt-get install sqlite3 libsqlite3-dev
I think you can replace the header:
#include <QtWebKit>
#include <QWebView>
with:
#include <Qt/QtGui>
Simple code:
#include <QCoreApplication>
#include <QGraphicsWebView>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}
Sample .pro:
QT += core gui declarative network webkit multimedia
TARGET = QTTest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
And error I get:
C1083: Cannot open include file: 'QGraphicsWebView': No such file or directory
What the is going on there in QT5? this class shall Be included like this and so I shall see no such error? I do not get some fancy QT5 new feature?
In the line
QT += core gui declarative network webkit multimedia
replace webkit by webkitwidgets :
QT += core gui declarative network webkitwidgets multimedia