Raspberry Pi 2 Qt app crash - c++

My application randomly crashes. I have used web view to load some URLs and there is always a warning.
qnetworkreplyimplprivate :: error: internal problem, this method must only called ones stack
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setAcceptDrops(true);
web->load(QString("http:my url"));
// QThread *webThread = new QThread;
// web.moveToThread(webThread);
web->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); //Handle link clicks by yourself
connect(web, SIGNAL(linkClicked(QUrl)),this,SLOT(urlCliked(QUrl)));
web->showMaximized();
}

The web pointer is dangling. It should be initialized to point to something. You probably need something like:
web = new QWebView(this);
in your constructor before accessing web as in web->load(QString("http:my url"));
You would also need to include the corresponding header:
#include <QWebView>

I was using Qt version 5.3 on raspberry pi 2 and i have found that i was using improper gcc version within the Qt.
so make sure to use the same Qt version with the correct gcc version.

Related

Qt Creator projects breaking: "symbols not found for architecture x86_64"

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

Qt3DWindow performance issue on Ubuntu 17.10

My problem is that I want to create a Qt3DWindow which I embed in my program using QWidget::createWindowContainer.
I now upgraded to Ubuntu 17.10 but as soon as I add the container widget my CPU load goes up to 100% constant.
This worked already under Ubuntu 16.04 and Windows.
Does anyone know this issue or maybe even have a solution? Or do I have to downgrade to Ubuntu 16.04 again?
A minimally working example is creating a new project in Qt Creator and selecting Qt Widgets Application and, finally, replacing the code in the mainwindow.cpp with the following:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QHBoxLayout>
#include <Qt3DExtras/Qt3DWindow>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->centralWidget->setLayout(new QHBoxLayout());
Qt3DExtras::Qt3DWindow *window = new Qt3DExtras::Qt3DWindow;
QWidget *widget = QWidget::createWindowContainer(window);
ui->centralWidget->layout()->addWidget(widget);
}
MainWindow::~MainWindow()
{
delete ui;
}
Now add 3dextras to QT += core gui in the .pro file of your project and run it. This produces the high CPU load on my machine.

Specific websites throwing an exception in QWebView

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.

QWebView doesnt load any webpage

i am struggling a bit with my project and the thing that is making me really annoyed right now is QWebview. So i tried to create a new project. In this new project all have is blank Qt widget application with one webview added from Qt Designer.
The problem is as the header says, my webview is not willing to load any webpage
i have tried all sorts of possibilities for webpage:
http://google.com
https://google.com
http://www.google.com
https://www.google.com
www.google.com
None of which works, all just give blank page as if about:blank
this is the code
#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);
ui->webView->load(QUrl("http://www.google.com"));
}
MainWindow::~MainWindow()
{
delete ui;
}
I didn't forgot to put QT+= webkitwidgets in pro, also included all libs.
Any suggestions?
Oukey i resolved my problem.
Still dont know what was wrong with QWebView instead i used QWebEngineView and that worked like a charm.
Maybe since its chromium that is the reason.
Thanks all for their inputs.

Qt linking problems

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "dialog.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setCentralWidget(ui->plainTextEdit);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_actionDoit_triggered()
{
Dialog D;
D.setModal(true);
D.exec();
}
This small piece of code is giving me linker errors LNK2019 and LNK1120
If I remove the three lines in function void MainWindow::on_actionDoit_triggered(), it works. The tutorial I am following didn't warn of linker problems
Apparently, you got it working without changing the code just by re-running qmake explicitly.
The reason is most likely the fact that you modified your qmake project file(s), and QtCreator has issues with knowing when to re-run qmake properly.
There is a long-standing bug about it:
Creator should know when to rerun qmake