I am using QT (version 5.4 msvc2013_64) with of-course vs2013. The compilation is successful but when running not every thing functions. Before with vs2010 and QT (i think version 5.1 msvc_2010_opengl do not remember exactly) every thing was working but now things are wried which maybe typical with the start of newer versions but need to be resolved. I also got other issues with this but lets get this resolved first as maybe others will be resolved too else I will post another question for the other problems. Of-course If i do not see a solution to this problem with the current QT and vs I will switch to vs2012 (requires downloading and installing); Maybe then everything will work as before. Thanks in advance.
ui_ta7feezquran.h
/********************************************************************************
** Form generated from reading UI file 'ta7feezquran.ui'
**
** Created by: Qt User Interface Compiler version 5.4.1
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_TA7FEEZQURAN_H
#define UI_TA7FEEZQURAN_H
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLabel>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QToolBar>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_Ta7feezQuranClass
{
public:
QWidget *centralWidget;
QLabel *a;
QMenuBar *menuBar;
QToolBar *mainToolBar;
void setupUi(QMainWindow *Ta7feezQuranClass)
{
if (Ta7feezQuranClass->objectName().isEmpty())
Ta7feezQuranClass->setObjectName(QStringLiteral("Ta7feezQuranClass"));
Ta7feezQuranClass->resize(572, 485);
centralWidget = new QWidget(Ta7feezQuranClass);
centralWidget->setObjectName(QStringLiteral("centralWidget"));
a = new QLabel(centralWidget);
a->setObjectName(QStringLiteral("a"));
a->setGeometry(QRect(-30, -20, 601, 471));
a->setPixmap(QPixmap(QString::fromUtf8(":/Ta7feezQuran/Resources/Amasjed Alharam.jpg")));
a->setScaledContents(true);
Ta7feezQuranClass->setCentralWidget(centralWidget);
menuBar = new QMenuBar(Ta7feezQuranClass);
menuBar->setObjectName(QStringLiteral("menuBar"));
menuBar->setGeometry(QRect(0, 0, 572, 21));
menuBar->setLayoutDirection(Qt::RightToLeft);
Ta7feezQuranClass->setMenuBar(menuBar);
mainToolBar = new QToolBar(Ta7feezQuranClass);
mainToolBar->setObjectName(QStringLiteral("mainToolBar"));
Ta7feezQuranClass->addToolBar(Qt::TopToolBarArea, mainToolBar);
retranslateUi(Ta7feezQuranClass);
QMetaObject::connectSlotsByName(Ta7feezQuranClass);
} // setupUi
void retranslateUi(QMainWindow *Ta7feezQuranClass)
{
Ta7feezQuranClass->setWindowTitle(QApplication::translate("Ta7feezQuranClass", "Ta7feezQuran", 0));
a->setText(QString());
} // retranslateUi
};
namespace Ui {
class Ta7feezQuranClass: public Ui_Ta7feezQuranClass {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_TA7FEEZQURAN_H
ta7feezquran.h
#ifndef TA7FEEZQURAN_H
#define TA7FEEZQURAN_H
#include <QtWidgets/QMainWindow>
#include "ui_ta7feezquran.h"
class Ta7feezQuran : public QMainWindow
{
Q_OBJECT
public:
Ta7feezQuran(QWidget *parent = 0);
~Ta7feezQuran();
private:
Ui::Ta7feezQuranClass ui;
};
#endif // TA7FEEZQURAN_H
ta7feezquran.cpp
#include "ta7feezquran.h"
Ta7feezQuran::Ta7feezQuran(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
}
Ta7feezQuran::~Ta7feezQuran()
{
}
main.cpp
#include "ta7feezquran.h"
#include <QtWidgets/QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Ta7feezQuran w;
w.show();
return a.exec();
}
ta7feezquran.qrc
<RCC>
<qresource prefix="/Ta7feezQuran">
<file>Resources/Amasjed Alharam.jpg</file>
</qresource>
</RCC>
Some Application features used, for example images, multimedia, print support, etc., require the use of qt plugins.
The required plugins should be copied to the executable folder (folder where .exe file is included) by copying the plugin folders (with the dlls included) and pasting them inside the executable folder. Every thing else should work as expected.
In this case imageformats folder (with qjpeg.dll included as the file used is jpg) is needed to copied.
Related
I have been using QGraphicsScene and QGraphicsVideoItem as my canvas. And to control them, I've chosen to use qml and QQuickWidget to develop custom objects easily for a different module. However, I quickly ran into an issue where the QGraphicsVideoItem would not render in the QGraphicsScene but rather inside the QQuickWidget (both when the widget is empty or with a qml source attached). And the issue seems to be reproducible using a fresh project as well just by placing an empty QQuickWidget(through qt designer) anywhere inside the main ui.
Here is the reproducible code:
#include "QtGuiApplication1.h"
QtGuiApplication1::QtGuiApplication1(QWidget *parent): QMainWindow(parent)
{
ui.setupUi(this);
QGraphicsView* view = new QGraphicsView(ui.widget);
QGraphicsScene* scene = new QGraphicsScene();
QGraphicsVideoItem* video = new QGraphicsVideoItem();
QMediaPlayer* player = new QMediaPlayer();
QUrl path = QUrl::fromLocalFile("D:/My Documents/Videos/XIII.mp4");
QVBoxLayout* layout = new QVBoxLayout();
layout->addWidget(view);
ui.widget->setLayout(layout);
video->setFlags(QGraphicsVideoItem::ItemIsMovable | QGraphicsVideoItem::ItemIsFocusable | QGraphicsVideoItem::ItemIsSelectable);
video->setPos(100, 100);
//view->setSceneRect(QRectF(QPointF(100, 100), QPointF(800, 600)));
view->setScene(scene);
player->setMedia(path);
player->setVideoOutput(video);
scene->addItem(video);
player->play();
view->show();
}
#pragma once
#include "ui_QtGuiApplication1.h"
#include <QtCore>
#include <QDebug>
#include <QGraphicsVideoItem>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QMediaPlayer>
#include <QUrl>
#include <QString>
class QtGuiApplication1 : public QMainWindow
{
Q_OBJECT
public:
QtGuiApplication1(QWidget *parent = Q_NULLPTR);
private:
Ui::QtGuiApplication1Class ui;
};
The issue immediately went away when I removed the widget from the ui file as well. So am I missing something here?
When you call ui.widget->setLayout(layout); you break the layout that was set in Qt Designer.
Instead of programmatically creating the QGraphicsView and QVBoxLayout in your *.cpp file, add them all in Qt Designer.
(If the issue still persists, please edit your original post and include your *.ui file)
Anyone got QT 5.6 working with OpenCV ?
Tried OpenCV latest 2.4.13 (at time of writing) and went back to OpenCV 2.4.9.
None worked - program will compile, link but crash on "During Startup program exited with code 0xc0000139". I never had any problems with QT 5.5.1 and OpenCV.
Here is stripped down code:
**mainwindow.cpp:**
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <opencv/cv.h>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
cv::Mat image = cv::imread("C:/Users/foo/pics/cheetah.jpg");
cv::namedWindow("My Image");
cv::imshow("My Image", image);
cvWaitKey(0);
}
MainWindow::~MainWindow()
{
delete ui;
}
**main.cpp (used default):**
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
**mainwindow.h: (used default)**
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
**test_opencv.pro:**
INCLUDEPATH += "C:\Users\foo\Downloads\opencv\build\include"
LIBS += -LC:\Users\foo\Downloads\opencv\build\lib \
-lopencv_core249.dll \
-lopencv_highgui249.dll \
-lopencv_imgproc249.dll \
-lopencv_features2d249.dll \
-lopencv_video249.dll \
-lopencv_calib3d249.dll
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = test_opencv
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
Path set:
C:\Qt\Tools\mingw492_32\bin
C:\Qt\5.6\mingw49_32\bin
C:\Users\foo\Downloads\opencv\build\bin
QT works fine with no OpenCV calls. With above code, running with QT Debug will see this:
"During Startup program exited with code 0xc0000139".
QT Error message
I have double checked my path. The OpenCV DLLs are defined in the Path. problem is not about not finding the runtime dynamically link dlls. I also checked my System32 and other directories for any old OpenCV dlls that might interfere as the path is traversed. No issues.
OpenCV was built with CMake and successfully build and installed. No issues there.
Thanks
Sean
Hello so i have a BIG problem with QWebViewEngine so far. Because all i did was created a QWebEngineView and said .load(QUrl("http://google.com")) and then .showFullScreen(). On start the application took about 130MB of RAM. When i pressed feel lucky on google and the page loaded suddenly the RAM started to climbing by 200mb each second and it stopped when there was no more free RAM.
Anyone had this problem, or experience with QWebEngineView.
I know its Chormium, but it seems to me as if it wasnt working correctly.
Any suggestions how to correct this?
Edited 14/08/2015 14:12
here is the code(note that most of it is commented):
#include "mainwindow.h"
#include <QtWebEngineWidgets/QtWebEngineWidgets>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QScopedPointer>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
view = new QWebEngineView();
manager = new QNetworkAccessManager();
settings = new QSettings(":/settings.ini",QSettings::IniFormat);
// connect(view,SIGNAL(loadFinished(bool)),this,SLOT(CheckPage()));
// connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(connection(QNetworkReply*)));
// errorOpen=false;
settings->beginGroup("URL");
myUrl = settings->value("curUrl").toString();
settings->endGroup();
// view->load(myUrl);
view->load(QUrl("http://google.com"));
view->showFullScreen();
settings->deleteLater();
}
MainWindow::~MainWindow()
{
// delete view;
// delete manager;
}
I can't reproduce under qt5-mac #5.4.2_1 from macports on OS X 10.9:
//main.cpp
#include <QtWebEngineWidgets>
#include <QApplication>
int main(int argc, char ** argv)
{
QApplication a(argc, argv);
QWebEngineView view;
view.load(QUrl("http://google.com"));
view.showFullScreen();
return a.exec();
}
# chromium-32008560.pro
QT += webenginewidgets
TARGET = chromium-32008560
TEMPLATE = app
SOURCES += main.cpp
I'm learning to build Qt + CUDA applications on linux (Ubuntu 12.04 64 bit). For starters, I am trying to build an application that checks the number of CUDA enabled devices on my computer.
I am able to launch the application from within Qt Creator but not by double clicking on the app. I can run it by issuing ./device_query in the terminal (the name of the app is device_query).
I have a simple UI (the default created by Qt Creator when a Qt gui app is created)
Here are the other files
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <cuda_runtime.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
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
int count;
cudaGetDeviceCount(&count); //when this line is added, unable to double click and launch
}
MainWindow::~MainWindow()
{
delete ui;
}
main.cpp
#include <QtGui/QApplication>
#include "mainwindow.h"
#include <QtDebug>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
.pro file
QT += core gui
TARGET = device_query
TEMPLATE = app
HEADERS = mainwindow.h
SOURCES += main.cpp\
mainwindow.cpp
FORMS += mainwindow.ui
INCLUDEPATH += /usr/local/cuda/include
LIBS += -L/usr/local/cuda/lib64/ -lcudart
Why is it that I am not able to run the application by double clicking it?
The issue is probably with $LD_LIBRARY_PATH not being set for the application when it is launched by double-click. In Nsight Eclipse Edition we have a shell script that initializes the environment and then starts the IDE - this way you can start Nsight from the desktop menus.
What is wrong with the code bellow? When I compile it I get a warning that file not found. Something is invalid. I'm probably making a few mistakes here. I think the problem is perhaps with the way I inherit from QWidget.
#include <QtGui/QApplication>
#include "filedialogs.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
FileDialogs w;
w.openFile();
return 0;
}
#ifndef FILEDIALOGS_H
#define FILEDIALOGS_H
#include <QWidget>
class QFileDialog;
class FileDialogs : public QWidget
{
public:
FileDialogs(QWidget *parent = 0);
~FileDialogs();
void openFile();
};
#endif // FILEDIALOGS_H
#include <QFileDialog>
#include "filedialogs.h"
FileDialogs::FileDialogs(QWidget *parent)
: QWidget(parent)
{
}
FileDialogs::~FileDialogs()
{
}
void FileDialogs::openFile()
{
QString filename = QFileDialog::getOpenFileName(
this,
tr("Open Document"),
QDir::currentPath(),
tr("Document files (*.doc *.rtf);;All files (*.*)") );
if( !filename.isNull() )
{
qDebug( filename.toAscii() );
}
}
#-------------------------------------------------
#
# Project created by QtCreator 2011-07-29T19:06:33
#
#-------------------------------------------------
QT += core gui
TARGET = exX
TEMPLATE = app
SOURCES += main.cpp\
filedialogs.cpp
HEADERS += filedialogs.h
This error message is emitted by the MOC compiler. You are missing the Q_OBJECT macro. Put it in your class declaration like this:
class FileDialogs : public QWidget
{
Q_OBJECT
public:
....
I know this Question is very old. But in my case it was another problem.
I had to include the path of the headers manually in the .pro file.
INCLUDEPATH += src/subdir