Qt Widgets FullScreen Margin - c++

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.

Related

QT qDebug() does not print anything in IDE console

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.

The program has unexpectedly finished in QT opencv

I know that this has been posted many times,but I could not find the solution from previous posts. I followed tutorial on How to setup Qt and openCV on Windows from wiki Qt.
My .pro file and mainwindows.cpp are shown below. I wanted to open image following the example. What is wrong here? Checked the opencv version and it is the same as libs included. The PATH is also correct.
The cpp file
#include "ui_mainwindow.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
cv::Mat image = cv::imread("C://1.jpg", 1);
cv::namedWindow("My Image");
cv::imshow("My Image", image);
}
MainWindow::~MainWindow()
{
delete ui;
}
and
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = opencvtest
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
INCLUDEPATH += C:\opencv\build\include
LIBS += C:\opencv-build\bin\libopencv_core451.dll
LIBS += C:\opencv-build\bin\libopencv_highgui451.dll
LIBS += C:\opencv-build\bin\libopencv_imgcodecs451.dll
LIBS += C:\opencv-build\bin\libopencv_imgproc451.dll
LIBS += C:\opencv-build\bin\libopencv_features2d451.dll
LIBS += C:\opencv-build\bin\libopencv_calib3d451.dll
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
When program crashes like that under Qt Creator, and you have extra libraries, the very likely reason is that the extra libraries are missing from the runtime PATH.
In this case, you need to add C:\opencv-build\bin to the PATH. There are at least 3 ways to go about it.
Edit the system environment, so that the relevant directory is always in the system PATH. You need to restart Qt Creator for this change to take effect. This is not the recommended way, unless you actually want these things in there also for other purposes.
You can edit the Build environment of the project under Qt Creator Project view. There's separate configuration for each build type, so you may need to do this to them all separately, which both good and bad. It is good, because then you can have different directory for different builds (for example debug vs relase, MSVC vs MinGW builds). It's bad because it's extra hassle and makes it easier to have something wrong.
You can add it to the run environment in the Qt Creator Project view. Then it will be the same for all build types.
In this case, 3 is probably the way to go.
Qt Creator annoyingly does not display any information about which DLL is missing, it just says the program crashed. This can be solved by instead string the "Qt command prompt" for the correct toolchain from Windows Start menu (search Qt and you should find it). Then go to the built .exe directory and run the .exe. You should now get an error dialog where Windows tells you which DLL it failed to find. Then you can look where that DLL is and add it to the path and try again, until the program starts. After you know the directories using this method, you can then add them to Qt Creator as explained above.

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.