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
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.
For my project i need a GUI and library called "STM32CubeProgrammer CLI".
They include some example C++ projects with VS and QT (both only command line, no GUI).
I'm able to compile and work with them.
In the next step I created a QT Widgets Application and add the STM library but the program crash instantly.
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
$$PWD/../../../include/CubeProgrammer_API.h \
$$PWD/../../../include/DeviceDataStructure.h \
FORMS += \
mainwindow.ui
#comment out that line and the programm works
win32: LIBS += -L$$PWD/../../../lib/ -lCubeProgrammer_API
INCLUDEPATH += $$PWD/../../../include
DEPENDPATH += $$PWD/../../../include
This is the main.cpp I don't edit any "window" or other files, I don't even use a function of the dll.
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
The linker find the dlls, but the program only crashes if I'm using a GUI, a simple cmd program dont crash. Just for fun I added Qlibrary, but the program crashes befor.
I'm using qmake, QT 5.14.2 MinGW-32bit and QT Creator 4.11.1.
While running my code I am getting a Write Access Violation Exception when it tries to use QWebView:
Minimal compilable code for reproducing the error
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtWebKitWidgets/QWebView>
#include <QUrl>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QWebView *wv = new QWebView(this);
wv->load(QUrl("http://steamcommunity.com/"));
setCentralWidget(wv);
}
MainWindow::~MainWindow()
{
delete ui;
}
The pro file also includes webkitwidgets and network:
QT += core gui webkitwidgets network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = MyApp
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
Error Hints
The error I get looks like this:
ASSERTION FAILED: leftSide->category() != CalcOther && rightSide->category() != CalcOther
css\CSSCalculationValue.cpp(290) : WebCore::CSSCalcBinaryOperation::create
1 0354A5B7
2 02E58E41
3 02E59520
...
I can't provide a stack trace because the error is in one of the Qt files, but here is the disassembly:
The error only occurs on specific webpages (e.g. steamcommunity.com) but not others. Is it possible that some sites just break Qt's API?
compiler: MSVC2013 x86
Qt version: Qt 5.5.0
Turns out that this error is actually a Qt bug.
Its status can be viewed here: Qt Bug Report
Using the new Qt WebEngine Widgets module worked great as a replacement for me.
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>
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