Hey guys,
I've been having an error with a pretty simple Qt and Qwt application that I've written. I keep on getting this error when I try to run it from Qt Creator (in release mode):
Starting C:\Users\Chris\Documents\Robotics2011SVN\TestCanTo pside3\release\TestCanTopside.exe...
Invalid parameter passed to C runtime function.
Invalid parameter passed to C runtime function.
QWidget: Must construct a QApplication before a QPaintDevice
The program has unexpectedly finished.
C:\Users\Chris\Documents\Robotics2011SVN\TestCanTo pside3\release\TestCanTopside.exe exited with code 62097
Other times it exits with Error Code 3.
Also, after it (my application) has crashed, I was able to see the Windows crash file that it created, and it mentioned QtCored4.dll even though I'm building it for release. Also, after running the .exe (release) through Dependency Walker, it said that it had issues finding QtCored4.dll and QtCore4.dll. Why would it look for both? As a side note, I'm running on Win7 64bit and it said that the different .dll's were for different CPUs (x86 vs x64). Could that be my issue?
I compiled Qwt with mingw32 and I also compiled Qt Creator with mingw32 (both as dynamic), and the plugin seems to work fine. My application worked fine this morning, but for no apparent reason things just changed. I can run an .exe that I compiled earlier today just fine, but I can't compile and run any newer .exe's.
What am I doing wrong here and how can I fix it? I've been all over Google and the forums, but I can't figure this out (I'm relatively new to Qt and C++, switched from Arduino programming to Qt in July 2011).
Here's my code:
*.pro
Code:
QT += core gui\ network INCLUDEPATH += C:\Qwt-6.0.1\include LIBS += C:\Qwt-6.0.1\lib\qwt.dll #QWT_LOCATION = C:/qwt-6.0.1-source #INCLUDEPATH += $${QWT_LOCATION}/src #LIBS += -L$${QWT_LOCATION}/lib -lqwt CONFIG += release TARGET = TestCanTopside TEMPLATE = app SOURCES += main.cpp\ mainwindow.cpp HEADERS += mainwindow.h FORMS += mainwindow.ui
*.h
Code:
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include "QtNetwork/qhostaddress.h" #include "QtNetwork/qudpsocket.h" #include "QtNetwork/qabstractsocket.h" #include "QNetworkInterface" #include "QHostAddress" #include "QtNetwork" #include "QTextStream" #include <Qwt/qwt.h> #include <Qwt/qwt_plot_curve.h> #include <Qwt/qwt_plot.h> #include <Qwt/qwt_series_data.h> #include <QPointF> #include <Qwt/qwt_plot_marker.h> #include <Qwt/qwt_abstract_scale_draw.h> #include <Qwt/qwt_scale_draw.h> #include <QPainter> #include <QPalette> #include <Qwt/qwt_dial.h> #include <Qwt/qwt_dial_needle.h> #include <Qwt/qwt_compass.h> #include <Qwt/qwt_compass_rose.h> namespace Ui { class MainWindow; } class QUdpSocket; { Q_OBJECT public: ~MainWindow(); private slots: void on_sendButton_clicked(); void findHostIP(); void on_configButton_clicked(); void processPendingDatagrams(); private: Ui::MainWindow *ui; QTime *myTime; QwtPlotCurve *myCurve; QVector<QPointF> myPoints; int index; double depthReadout; double otherReadout; double voltsReadout; double ampsReadout; double headingReadout; double tempReadout; QUdpSocket *udpSocket; QUdpSocket *rxUdpSocket; int rxPort; int listenPort; QHostAddress txIP; bool userIP; QString rxString; }; #endif // MAINWINDOW_H
*.cpp
Code:
#include "mainwindow.h" #include "ui_mainwindow.h" ui(new Ui::MainWindow) { ui->setupUi(this); rxUdpSocket->bind(12345); //found in book connect(rxUdpSocket, SIGNAL(readyRead()), this, SLOT(processPendingDatagrams())); findHostIP(); //Set Tab order for UI setTabOrder(ui->rxIPLE, ui->portLE); setTabOrder(ui->portLE, ui->rxPortLE); setTabOrder(ui->rxPortLE, ui->dsbMaxDepth); setTabOrder(ui->dsbMaxDepth,ui->configButton); setTabOrder(ui->configButton, ui->packetLE); setTabOrder(ui->packetLE, ui->sendButton); //Setup Qwt Stuff ui->plotDepth->setAxisAutoScale(2, false); //turn off y axis auto scale ui->plotDepth->setAxisScale(0,-4.0,0,0.5); //set y axis scale ui->plotDepth->setAutoReplot(true); //automatically update the plot ui->plotDepth->setAxisMaxMinor(2, 30); //x axis minor ticks = 30 myTime->start(); myCurve->attach(ui->plotDepth); //connect the curve to the graph index = 0; //the index holds the number of points //Setup the colors of the compass ui->compass->setLineWidth(0); ui->compass->setScaleTicks(0, 0, 3); //Create tick marks on the compass QMap<double, QString> map; for ( double d = 0.0; d < 360.0; d += 30.0 ) { QString label; label.sprintf("%.0f", d); map.insert(d, label); } ui->compass->setLabelMap(map); ui->compass->setScale(36, 5, 0); //Setup the needle on the compass ui->compass->setPalette(*colorGroup); ui->compass->setOrigin(270.0); ui->compass->setValue(0.0); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_sendButton_clicked() { if(userIP == true) { udpSocket->writeDatagram(myDatagram.data(), myDatagram.size(), txIP, rxPort); } else { udpSocket->writeDatagram(myDatagram.data(), myDatagram.size(), } } void MainWindow::on_configButton_clicked() { rxPort = ui->portLE->text().toInt(); //set port listenPort = ui->rxPortLE->text().toInt(); //set port to listen on rxUdpSocket->close(); rxUdpSocket->bind(listenPort); //found in book if(ui->rxIPLE->text() != NULL) //if user added IP address { txIP = txStrIp; //Convert to IP Address userIP = true; } else { userIP = false; } ui->barDepth->setMaximum(int(ui->dsbMaxDepth->value()*100)); ui->plotDepth->setAxisScale(0,-1.0*ui->dsbMaxDepth->value(),0,0.5); //set y axis scale } void MainWindow::findHostIP() //found this code online, modified it to only show IP addresses (local) { QStringList items; ui->listWidget->clear(); { { if ( interface.hardwareAddress() != "00:00:00:00:00:00" && entry.ip().toString().contains(".")) items << interface.name() + " " + entry.ip().toString(); } } ui->listWidget->addItems(items); } void MainWindow::processPendingDatagrams() { QByteArray rxDatagram; QString rxString; do { rxDatagram.resize(rxUdpSocket->pendingDatagramSize()); rxUdpSocket->readDatagram(rxDatagram.data(), rxDatagram.size()); } while(rxUdpSocket->hasPendingDatagrams()); rxString = (tr("\"%1\"").arg(rxDatagram.data())); //turn datagram into string //ui->rxPacketLabel->setText(tr("\"%1\"").arg(rxDatagram.data())); ui->rxPacketLabel->setText(rxString); packetStream >> depthReadout >> voltsReadout >> ampsReadout >> tempReadout >> headingReadout >> otherReadout; ui->lcdDepth->display(depthReadout); ui->barDepth->setValue(depthReadout * 100); ui->lcdOther->display(otherReadout); ui->lcdVolts->display(voltsReadout); ui->lcdAmps->display(ampsReadout); ui->lcdTemp->display(tempReadout); ui->barHeading->setValue(headingReadout*10); //Qwt stuff myPoints[index].setX(myTime->elapsed()); myPoints[index].setY(-1.0*depthReadout); index++; myCurve->setSamples(myPoints); ui->plotDepth->setAxisScale(2, myTime->elapsed()-10000, myTime->elapsed(), 60000); ui->compass->setValue(headingReadout); }
Qt version 4.7.3
Qwt verson 6.0.1
Thanks for the help! I really appreciate it!
Chris
Added after 17 minutes:
I just thought I would include the contents of the file that Windows creates after the crash (WERF3C5.tmp.appcompat.txt)
Code:
<?xml version="1.0" encoding="UTF-16"?> <DATABASE> <EXE NAME="TestCanTopside.exe" FILTER="CMI_FILTER_PRIVACY"> <MATCHING_FILE NAME="TestCanTopside.exe" SIZE="120832" CHECKSUM="0x94AE05AA" MODULE_TYPE="WIN32" PE_CHECKSUM="0x23E1F" LINKER_VERSION="0x10000" LINK_DATE="11/11/2011 01:22:11" UPTO_LINK_DATE="11/11/2011 01:22:11" EXE_WRAPPER="0x0" FILE_ID="0000998a8720b1423260a4c557dddb609fdc3e996ea8" PROGRAM_ID="0000da39a3ee5e6b4b0d3255bfef95601890afd80709" /> </EXE> <EXE NAME="QtCored4.dll" FILTER="CMI_FILTER_THISFILEONLY"> <MATCHING_FILE NAME="QtCored4.dll" SIZE="31662865" CHECKSUM="0x8222D8C9" BIN_FILE_VERSION="4.7.3.0" BIN_PRODUCT_VERSION="4.7.3.0" FILE_DESCRIPTION="C++ application development framework." COMPANY_NAME="Nokia Corporation and/or its subsidiary(-ies)" PRODUCT_NAME="Qt4" FILE_VERSION="4.7.3.0" ORIGINAL_FILENAME="QtCored4.dll" LEGAL_COPYRIGHT="Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)." VERDATEHI="0x0" VERDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0x1E38A2B" LINKER_VERSION="0x10000" UPTO_BIN_FILE_VERSION="4.7.3.0" UPTO_BIN_PRODUCT_VERSION="4.7.3.0" LINK_DATE="03/30/2011 13:34:37" UPTO_LINK_DATE="03/30/2011 13:34:37" EXPORT_NAME="QtCored4.dll" EXE_WRAPPER="0x0" FILE_ID="0000c52acb9a6b94db7dc42c12e6257c82524f5e9c65" PROGRAM_ID="000377025cd5c5d05c0c34a33351fe5411c50000ffff" /> </EXE> <EXE NAME="kernel32.dll" FILTER="CMI_FILTER_THISFILEONLY"> <MATCHING_FILE NAME="kernel32.dll" SIZE="1114112" CHECKSUM="0x9725986B" BIN_FILE_VERSION="6.1.7601.17651" BIN_PRODUCT_VERSION="6.1.7601.17651" PRODUCT_VERSION="6.1.7600.16385" FILE_DESCRIPTION="Windows NT BASE API Client DLL" COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="Microsoft® Windows® Operating System" FILE_VERSION="6.1.7600.16385 (win7_rtm.090713-1255)" ORIGINAL_FILENAME="kernel32" INTERNAL_NAME="kernel32" LEGAL_COPYRIGHT="© Microsoft Corporation. All rights reserved." VERDATEHI="0x0" VERDATELO="0x0" VERFILEOS="0x40004" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0x1164FD" LINKER_VERSION="0x60001" UPTO_BIN_FILE_VERSION="6.1.7601.17651" UPTO_BIN_PRODUCT_VERSION="6.1.7601.17651" LINK_DATE="07/16/2011 04:27:04" UPTO_LINK_DATE="07/16/2011 04:27:04" EXPORT_NAME="KERNEL32.dll" VER_LANGUAGE="English (United States) [0x409]" EXE_WRAPPER="0x0" /> </EXE> </DATABASE>
If you look at line 7, you'll see that QtCored4.dll is mentioned, even though I built this using the "release" settings of Qt Creator.
I'm thinking that is tied to my issue, but I don't know how to fix it.
Thanks!
Chris
