I am trying to write a simple camara app. I created a new Project and add the EDSDK headers and the lib. Also i have added the init command EdsInitializeSDK().
test.pro
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Test
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
LIBS += -L".\EDSDK.lib"
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <EDSDK.h>
#include <EDSDKErrors.h>
#include <EDSDKTypes.h>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
EdsError err=EDS_ERR_OK;
err = EdsInitializeSDK();
}
MainWindow::~MainWindow()
{
delete ui;
}
the main.cpp and mainwindow.h are not modified.
it compiled, but when i want to start the programm it crash without any error.
In debug i become the error 0xc0000135
I use the Canon_Camara_SDK_Kit_v2_14 with Qt on Win 7.
The EDSDK.lib are in the src and in the build Folder.
I have no Idea whats wrong
Thanks!
Related
I'm having problems including winscard.lib in my QT project.
I have windows 10 x64 and I downloaded the microsoft sdk V7.1 because I didn't have the winscard library in the microsoft sdk v10.
Now, my .pro file looks like this:
QT += core gui sql
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = NFC
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
main.cpp \
mainwindow.cpp \
globs.cpp \
newcard.cpp \
newcircuitnumber.cpp
HEADERS += \
mainwindow.h \
globs.h \
newcard.h \
newcircuitnumber.h
FORMS += \
mainwindow.ui \
newcard.ui \
newcircuitnumber.ui
INCLUDEPATH += "C:\Program Files\Microsoft SDKs\Windows\v7.1\Include"
LIBS += -L"C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\IA64"
LIBS += -winscard -lz
mainwindow.h
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDir>
#include <QDebug>
#include <QMessageBox>
#include <QSqlQuery>
#include "globs.h"
#include "qt_windows.h"
#include "winnt.h"
#include "winscard.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
SCARDCONTEXT cardContext;
LPWSTR mszReaders;
DWORD dwReaders;
SCardEstablishContext(SCARD_SCOPE_USER,NULL,NULL,&cardContext);
dwReaders = SCARD_AUTOALLOCATE;
SCardListReadersW(cardContext,NULL,(LPWSTR)&mszReaders,&dwReaders);
QByteArray buffer;
wchar_t *it = mszReaders;
while(*it !='\0')
{
buffer.append(QChar(*it));
*it++;
}
qDebug()<<buffer;
}
The error I get when I try to compile are the following:
Errors
Can somebody point me to a solution? What am I doing wrong?
Thanks a lot in advance.
I am using Qt5.4.3 and at some point, Qt prints out message like this
LEAK: 145 CachedResource
LEAK: 4432 WebCoreNode
I try to display a webpage on a Qt application, but whatever the webpage is, memory always leaks.
Here is the all code of project named"test"(I add the webview control in mainwindow.ui)
#test.pro
QT += core gui webkit
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets webkitwidgets multimedia multimediawidgets
TARGET = EchartDemo
TEMPLATE = app
SOURCES += main.cpp\
widget.cpp
HEADERS += widget.h
FORMS += widget.ui
INCLUDEPATH += $$PWD
MOC_DIR = temp/moc
RCC_DIR = temp/rcc
UI_DIR = temp/ui
OBJECTS_DIR = temp/obj
DESTDIR = bin
//main.cpp
#include "widget.h"
#include <QApplication>
#include <QTextCodec>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.showMaximized();
return a.exec();
}
//widget.h
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
private:
Ui::Widget *ui;
};
#endif // WIDGET_H
//`widget.cpp`
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
ui->webView->load(QUrl("file:///"+qApp->applicationDirPath()+"/html/hao.html"));
}
Widget::~Widget()
{
delete ui;
}
//hao.html
<meta http-equiv="Refresh" content="0; url=http://www.hao123.com/?1460255739"/><meta property="shurufa:url-navigate" content="985" />
In order to show the webpage normally, you should put the html file to the folder \build-EchartDemo-Desktop_Qt_5_4_2_MinGW_32bit-Debug\bin\html.
Of course, you can change the content of the hao.html file to whatever you like.
Why do I have these memory leaks?
This is a known bug in Qt and these "memory leaks" are only warnings in some cases. You can read more about it here : Qt Bug 40373, and also see the other bug reports mentioning those leaks.
Also, you should consider to use QWebEngineView which is much better ;) (and update to Qt5.6, but it is another story!).
I tried using QSound in my project but I am getting an undefined refrence to _imp_ZN6Q:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtMultimedia/QSound>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
ui->setupUi(this);
QSound player;
QSound::play("E:\songs");
}
MainWindow::~MainWindow()
{
delete ui;
}
In your project file (.pro) add
QT += multimedia
QT += multimedia
and add :
#include <QtMultimedia/QSound>
QSound newMessage("sound/newChat.wave");
newMessage.play();
I try to use QwtPlot, but when i add this line to my MainWindow.cpp
QwtPlot *plot = new QwtPlot(QwtText("Demo"), this);
the application compile and link without errors, but when I try to run it I get
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff514227c in ?? () from /usr/lib/libQtGui.so.4
without any backtrace. My .pro file:
INCLUDEPATH += /usr/include/qwt
CONFIG += qwt
LIBS += -lqwt
I'm using Qwt 6.0.2, Qt Creator 2.7.0 and have Qt 4.8.4 and 5.0.2 installed.
The error also occours when I create a "Qt Gui Application" (without .ui file) and just this code:
qwt-test.pro
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = qwt-test
TEMPLATE = app
INCLUDEPATH += /usr/include/qwt
CONFIG += qwt
LIBS += -lqwt
SOURCES += main.cpp\
MainWindow.cpp
HEADERS += MainWindow.hpp
main.cpp
#include "MainWindow.hpp"
#include <QApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
qDebug() << "main";
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
MainWindow.hpp
#ifndef MAINWINDOW_HPP
#define MAINWINDOW_HPP
#include <QMainWindow>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
};
#endif // MAINWINDOW_HPP
MainWindow.cpp
// MainWindow.cpp
#include "MainWindow.hpp"
#include <qwt_plot.h>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
QwtPlot *plot = new QwtPlot(QwtText("Demo"), this);
}
MainWindow::~MainWindow()
{
}
Thanks!
It was a problem with Qt Creator (or Qwt being incompatible with Qt 5), it recognized qmake as qmake for Qt 4 but it was for Qt 5. Fixing the versions in Options -> Build&Run -> Qt Versions and using Qt 4 for the project fixed the segfault.
I have created a Qt GUI application but I haven't touched anything regarding the GUI. I have modified mainwindow.cpp and the project file.
mainwindow.cpp:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QWebPage>
#include <QWebFrame>
QWebPage page;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(page.mainFrame(), SIGNAL(loadFinished(bool)), this, SLOT(pageLoaded1(bool)));
QUrl router("http://192.168.1.1");
page.mainFrame()->load(router);
}
MainWindow::~MainWindow()
{
delete ui;
}
untitled.pro:
#-------------------------------------------------
#
# Project created by QtCreator 2013-05-01T23:48:00
#
#-------------------------------------------------
QT += core gui webkit webkitwidgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
main.cpp:
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
Error:
---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Error!
Program: ...tled-Desktop_Qt_5_0_2_MSVC2010_32bit-Debug\debug\untitled.exe
Module: 5.0.2
File: global\qglobal.cpp
Line: 1977
ASSERT: "!"No style available without QApplication!"" in file kernel\qapplication.cpp, line 962
(Press Retry to debug the application)
---------------------------
Abort Retry Ignore
---------------------------
Extra characters are inserted here to bypass character requirement.
In main.cpp, make sure you create an application object, even if you don't use directly:
QApplication app;
// Below you can then create the window
Edit
The problem is that you are creating a QWebPage as a global object, and before the QApplication has been created. To solve the problem, make the page a member of the MainWindow class. Also make the page a pointer, otherwise you will get other problems.
i.e. in mainwindow.h:
private:
QWebPage* page;
in mainwindow.cpp:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QWebPage>
#include <QWebFrame>
// Remove this!!
// QWebPage page;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
// Create the page here:
page = new QWebPage(this);
connect(page.mainFrame(), SIGNAL(loadFinished(bool)), this, SLOT(pageLoaded1(bool)));
QUrl router("http://192.168.1.1");
page.mainFrame()->load(router);
}
MainWindow::~MainWindow()
{
delete ui;
}