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.
Related
I need qDebug(), qInfo(), qWarning(), qCritical, or qFatal() to print information to the QTCreator console. Now nothing of it doesn't work. I install QTCreator from repository.
Editing the qtlogging.ini didn't change anything. I added all possible tags to the. pro file.
Qt 5.15.2
Linux user 5.13.15-1-MANJARO #1 SMP PREEMPT x86_64 GNU/Linux
*.pro file:
QT += core gui sql
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += debug
CONFIG += console
*.h file:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QDebug>
#include <QComboBox>
#include <QString>
#include <QtSql>
...
*.cpp file:
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
qDebug() << "Check";
ui->setupUi(this);
load();
}
...
that happens because you set CONFIG += console and maybe you didn't uncheck this :
uncheck Run in Terminal.
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.
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.
I want to create a program that loads google in literally full screen, so I achieved opening my qt program in full screen using w.showFullScreen(); and it works perfectly, however when I add the QWebView and set it to centralWidget like this:
but when I run the program, I get some margins on the sides of the window, in other words the QWebView isn't literally in fullScreen harmoniously with the window which is, it looks like this:
I don't think my code is mistaken but here it is
untitled.pro:
#-------------------------------------------------
#
# Project created by QtCreator 2015-02-07T21:25:42
#
#-------------------------------------------------
CONFIG += release
QT += core gui
QT += webkitwidgets
main.cpp
w.showFullScreen();
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtWebKitWidgets>
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;
}
Thank you.
Your central widget have a layout. It's possible that you have layoutLeftMargin, layoutRightMargin, layoutTopMargin, layoutBottomMargin with others values than 0 got in you QtDesigner click on your central widget and at the down of you properties set the margins to 0.
#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