PDA

View Full Version : Qwt Data_Plot Example Runtime Error



AlphaWolfXV
2nd March 2009, 20:18
Hello all,
Firstly I am running QtCreator 0.9.2 / with Qt 4.5.0, on Windows Vista Business.

I followed the install instructions for qwt; and also built the examples at time of install. Next I opened the pro file of the example (data_plot) through QtCreator and everything worked nicely. (Had to add C:\qt\qtcreator\qt\bin; C:\qt\qtcreator\mingw\bin; c:\qwt-5.1.1\bin to the PATH Variable.)

After spending some time trying to apply the same concepts as the example in my own simple QDialog, I ran into an error on both Run and Debug: "This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.", Titled: "Microsoft Visual C++ Runtime Library". The Application Output window of QT Creator displays:
"Starting e:/data/qt_creator_projects/bin/DriveCycle.exe..."
"Invalid parameter passed to C runtime function."
"Invalid parameter passed to C runtime function."
""
"e:/data/qt_creator_projects/bin/DriveCycle.exe exited with code 3".

Here are the files I am working with:

DriveCycle.pro

include (E:/Data/Qt_Creator_Projects/qwtInclude.pri)
TARGET = DriveCycle
DESTDIR_TARGET = E:/Data/Qt_Creator_Projects/bin/DriveCycle

# TEMPLATE = app
SOURCES = main.cpp \
plotterdialog.cpp
HEADERS = plotterdialog.h

main.cpp

#include <QtGui/QApplication>
#include "plotterdialog.h"

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
PlotterDialog w;
w.show();
return a.exec();
}


plotterdialog.cpp

#include "plotterdialog.h"
#include <QHBoxLayout>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_text.h>

PlotterDialog::PlotterDialog(QWidget *parent)
: QWidget(parent)
{
lbl1 = new QLabel(tr("Good Morning"));
hbl1= new QHBoxLayout;
hbl1->addWidget(lbl1);
QwtText *txt1;
txt1 = new QwtText("Two Curves");
QwtPlot *myPlot;
double x[100], y1[100], y2[100];
myPlot = new QwtPlot(txt1->text(),parent);
//hbl1->addWidget(qPlot);
setLayout(hbl1);

}

PlotterDialog::~PlotterDialog()
{

}


plotterdialog.h

#ifndef PLOTTERDIALOG_H
#define PLOTTERDIALOG_H

#include <QtGui/QDialog>
#include <QtGui>

#include "plotter.h"
//#include <qwt_plot.h>

class QLabel;
class QHBoxLayout;
class PlotterDialog : public QWidget
{
Q_OBJECT

public:
PlotterDialog(QWidget *parent = 0);
~PlotterDialog();
QLabel* lbl1;
QHBoxLayout* hbl1;


};

#endif // PLOTTERDIALOG_H


qwtInclude.pri (included in DriveCycle.pro)

QT_ROOT = C:/Qt/QtCreator/Qt
QWT_ROOT = C:/qwt-5.1.1
MINGW_ROOT = C:/Qt/QtCreator/mingw
MyProjectRoot = E:/Data/QT_Creator_Projects/

SUFFIX_STR =
VVERSION = $$[QT_VERSION]
isEmpty(VVERSION) {

# Qt 3
debug {
SUFFIX_STR = $${DEBUG_SUFFIX}
}
else {
SUFFIX_STR = $${RELEASE_SUFFIX}
}
}
else {
CONFIG(debug, debug|release) {
SUFFIX_STR = $${DEBUG_SUFFIX}
}
else {
SUFFIX_STR = $${RELEASE_SUFFIX}
}
}

TEMPLATE = app

MOC_DIR = moc
INCLUDEPATH += $${QWT_ROOT}/src\
$${QWT_ROOT}/include/qwt5\
$${QT_ROOT}/include\
$${QT_ROOT}/bin\
$${MINGW_ROOT}/include\
$${MINGW_ROOT}/bin\
$${MINGW_ROOT}/lib


DEPENDPATH += $${QWT_ROOT}/src
OBJECTS_DIR = obj$${SUFFIX_STR}
DESTDIR = $${MyProjectRoot}/bin/$${SUFFIX_STR}
QMAKE_LIBDIR +=$${MINGW_ROOT}/lib

QWTLIB = qwt$${SUFFIX_STR}

win32 {
contains(CONFIG, QwtDll) {
DEFINES += QT_DLL QWT_DLL
QWTLIB = $${QWTLIB}$${VER_MAJ}
}

win32-msvc:LIBS += $${QWT_ROOT}/lib/$${QWTLIB}.lib
win32-msvc.net:LIBS += $${QWT_ROOT}/lib/$${QWTLIB}.lib
win32-msvc2005:LIBS += $${QWT_ROOT}/lib/$${QWTLIB}.lib
win32-g++:LIBS += -L$${QWT_ROOT}/lib -l$${QWTLIB}
}
else {
LIBS += -L$${QWT_ROOT}/lib -l$${QWTLIB}

}
# LIBS += $${QWT_ROOT}/lib/qwtd5.dll
LIBS -lqwt5

Application Output:
Starting e:/Data/QT_Creator_Projects/bin/DriveCycle.exe...
Invalid parameter passed to C runtime function.
Invalid parameter passed to C runtime function.

e:/Data/QT_Creator_Projects/bin/DriveCycle.exe exited with code 3

Much of the qwtInclude.pri was taken based on the data_plot example from the qwt-5.1.1 installed examples. As I said earlier, the example runs fine from its installed directory. So then I thought I would make a complete copy of the data_plot example in a new folder under qwt-5.1.1/examples called "mytest", in this folder I copied completely the main.cpp, data_plot.cpp, data_plot.h, and data_plot.pro; opened the pro file in qt creator and tried to run, which should be identical to the original example, and it duplicates the same error I experienced before. Any help/insight would be most welcome, I have been scouring the web looking for helpful hints related to this for a couple days now, which is partially why the pri file above has so many entries...

The only difference I have found so far between my 2 non-working versions and the working example is in the "Build Steps" -> "QMake"->"Arguments" (which are not changable from this screen):
Working example (qwt-5.1.1/examples/data_plot...):
"C:/qwt-5.1.1/examples/data_plot/data_plot.pro -spec win32-g++ -r"
Non-working examples (both) (qwt-5.1.1/examples/MyTest...):
"C:/qwt-5.1.1/examples/MyTest/data_plot.pro -spec win32-g++ -r CONFIG +=debug_and_release".

The only conclusions I have been able to draw from this so far is that the extra CONFIG statement must be a setting in QtCreator? Don't know if this is even remotely related to the issues I am seeing, just an observation.

Thanks to all in advance for the help, it is much appreciated!

bair
5th March 2009, 15:29
Probably there will be no runtime error if you build and run the release version, that's what happening with my test qwt projects. I don't understand why.

giusepped
3rd April 2009, 08:19
I have the same runtime errors.
Before, under XP, no problems.
But porting the same application under Vista fires this error.
I don't know if it's a problem of Qwt or Qt 4.5.
Waiting for help

giusepped
3rd April 2009, 08:37
I solved, or at least I reached a working solution.
My experience is as follows:

(First delete CONFIG += debug_and_release from your src.pro;)


Qt 4.5 + Qwt-5.2 ---> Doesn't work (Runtime errors)
Qt 4.5 + Qwt-5.1 ---> Works
Qt 4 + Qwt 5.1 ----> Works


I cannot figure out what does cause that configuration variable at all.:confused:

AlphaWolfXV
14th April 2009, 12:30
Thanks to all for your suggestions. It is now working... Thanks again! :)
:cool:

livewire
13th August 2009, 15:25
I'm using Qt 4.5.2 with Qwt 5.2.0 on Windows XP and it works with release builds (same error with debug release), so it seems to be caused not by issues with the versions, but by some settings.

agostain
7th September 2009, 11:49
i have the same problem. i port a linux app to windows. my project compiles . but when i start the app i get an runtime error. i have no idea , how to solve this problem. does anybody solve his problem?

jarosell
27th January 2010, 08:18
Hi,

I'm a newbie in the Qt - world and I'm starting to use the Qt environment and Qwt. I'm also experimenting that problem.

I'm writting a simple example based on realtime_plot and I get the same runtime error (either in debug or release version) when I execute it. The offending code is this:

MainWindow::MainWindow() : QMainWindow(){

addToolBar(toolBar());

d_plot = new RandomPlot(this); //<--- The error is raised here. d_plot is an object of class RandomPlot.
d_plot->setMargin(4);
setCentralWidget(d_plot);


initWhatsThis();
setAttribute(Qt::WA_DeleteOnClose);
}



I did some research and just found that the problem may be in the classes inheriting from QFrame but I cannot figure out what the problem is. I'm running Qt-Creator 4.6.0 and Qwt 5.2.0.

Regards,


Juan

jarosell
27th January 2010, 10:11
It's me again! :)

I think I found a solution to the problem.... I followed these steps (which were already posted in another thread) http://www.qtcentre.org/threads/26174-How-to-use-QWT-in-QT4-Creator-on-Windows?p=127178#post127178.

Now my first QWT application is up and running.

I hope it can help.


Regards,


Juan.