Results 1 to 4 of 4

Thread: Qwt Runtime Errors (Windows)

  1. #1
    Join Date
    Aug 2011
    Location
    California, USA
    Posts
    24
    Thanks
    4
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt Runtime Errors (Windows)

    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
    Qt Code:
    1. QT += core gui\
    2. network
    3.  
    4. INCLUDEPATH += C:\Qwt-6.0.1\include
    5. LIBS += C:\Qwt-6.0.1\lib\qwt.dll
    6.  
    7. #QWT_LOCATION = C:/qwt-6.0.1-source
    8. #INCLUDEPATH += $${QWT_LOCATION}/src
    9. #LIBS += -L$${QWT_LOCATION}/lib -lqwt
    10.  
    11. CONFIG += release
    12.  
    13. TARGET = TestCanTopside
    14. TEMPLATE = app
    15.  
    16.  
    17. SOURCES += main.cpp\
    18. mainwindow.cpp
    19.  
    20. HEADERS += mainwindow.h
    21.  
    22. FORMS += mainwindow.ui
    To copy to clipboard, switch view to plain text mode 

    *.h
    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5. #include "QtNetwork/qhostaddress.h"
    6. #include "QtNetwork/qudpsocket.h"
    7. #include "QtNetwork/qabstractsocket.h"
    8. #include "QNetworkInterface"
    9. #include "QHostAddress"
    10. #include "QtNetwork"
    11. #include "QTextStream"
    12. #include <Qwt/qwt.h>
    13. #include <Qwt/qwt_plot_curve.h>
    14. #include <Qwt/qwt_plot.h>
    15. #include <Qwt/qwt_series_data.h>
    16. #include <QPointF>
    17. #include <Qwt/qwt_plot_marker.h>
    18. #include <Qwt/qwt_abstract_scale_draw.h>
    19. #include <Qwt/qwt_scale_draw.h>
    20. #include <QPainter>
    21. #include <QPalette>
    22. #include <Qwt/qwt_dial.h>
    23. #include <Qwt/qwt_dial_needle.h>
    24. #include <Qwt/qwt_compass.h>
    25. #include <Qwt/qwt_compass_rose.h>
    26.  
    27. namespace Ui {
    28. class MainWindow;
    29. }
    30.  
    31. class QUdpSocket;
    32.  
    33. class MainWindow : public QMainWindow
    34. {
    35. Q_OBJECT
    36.  
    37. public:
    38. explicit MainWindow(QWidget *parent = 0);
    39. ~MainWindow();
    40.  
    41. private slots:
    42. void on_sendButton_clicked();
    43. void findHostIP();
    44. void on_configButton_clicked();
    45. void processPendingDatagrams();
    46. private:
    47. Ui::MainWindow *ui;
    48. QTime *myTime;
    49. QwtPlotCurve *myCurve;
    50. QVector<QPointF> myPoints;
    51. int index;
    52.  
    53. double depthReadout;
    54. double otherReadout;
    55. double voltsReadout;
    56. double ampsReadout;
    57. double headingReadout;
    58. double tempReadout;
    59. QUdpSocket *udpSocket;
    60. QUdpSocket *rxUdpSocket;
    61. int rxPort;
    62. int listenPort;
    63. bool userIP;
    64. QString rxString;
    65. };
    66.  
    67. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

    *.cpp
    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3.  
    4.  
    5. MainWindow::MainWindow(QWidget *parent) :
    6. QMainWindow(parent),
    7. ui(new Ui::MainWindow)
    8. {
    9. ui->setupUi(this);
    10. udpSocket = new QUdpSocket(this); //create UDP Socket(tx)
    11. rxUdpSocket = new QUdpSocket(this); //create UDP Socket(rx)
    12. rxUdpSocket->bind(12345); //found in book
    13. connect(rxUdpSocket, SIGNAL(readyRead()), this, SLOT(processPendingDatagrams()));
    14. findHostIP();
    15. //Set Tab order for UI
    16. setTabOrder(ui->rxIPLE, ui->portLE);
    17. setTabOrder(ui->portLE, ui->rxPortLE);
    18. setTabOrder(ui->rxPortLE, ui->dsbMaxDepth);
    19. setTabOrder(ui->dsbMaxDepth,ui->configButton);
    20. setTabOrder(ui->configButton, ui->packetLE);
    21. setTabOrder(ui->packetLE, ui->sendButton);
    22.  
    23. //Setup Qwt Stuff
    24. ui->plotDepth->setAxisAutoScale(2, false); //turn off y axis auto scale
    25. ui->plotDepth->setAxisScale(0,-4.0,0,0.5); //set y axis scale
    26. ui->plotDepth->setAutoReplot(true); //automatically update the plot
    27. ui->plotDepth->setAxisTitle(QwtPlot::xBottom, "Time in Seconds");
    28. ui->plotDepth->setAxisTitle(QwtPlot::yLeft, "Depth in Meters");
    29. ui->plotDepth->setAxisMaxMinor(2, 30); //x axis minor ticks = 30
    30. ui->plotDepth->axisScaleDraw(2)->enableComponent(QwtAbstractScaleDraw::Labels, false);
    31.  
    32. myTime = new QTime; //QTime for axis
    33. myTime->start();
    34.  
    35. myCurve = new QwtPlotCurve; //create the curve for the graph
    36. myCurve->setPen(QPen(QColor::QColor(65,105,225,255))); //set the curve color
    37. myCurve->attach(ui->plotDepth); //connect the curve to the graph
    38.  
    39. index = 0; //the index holds the number of points
    40.  
    41. //Setup the colors of the compass
    42. QPalette *colorGroup = new QPalette(Qt::lightGray, Qt::white, Qt::white, Qt::white, Qt::white, Qt::white, Qt::white, QColor::QColor(65,105,225,255), Qt::white);
    43.  
    44. ui->compass->setLineWidth(0);
    45.  
    46. ui->compass->setScaleComponents( QwtAbstractScaleDraw::Backbone |
    47. ui->compass->setScaleTicks(0, 0, 3);
    48.  
    49. //Create tick marks on the compass
    50. QMap<double, QString> map;
    51. for ( double d = 0.0; d < 360.0; d += 30.0 )
    52. {
    53. QString label;
    54. label.sprintf("%.0f", d);
    55. map.insert(d, label);
    56. }
    57. ui->compass->setLabelMap(map);
    58. ui->compass->setScale(36, 5, 0);
    59.  
    60. //Setup the needle on the compass
    61. ui->compass->setPalette(*colorGroup);
    62. ui->compass->setNeedle(new QwtDialSimpleNeedle(QwtDialSimpleNeedle::Ray,
    63. true, QColor::QColor(65,105,225,255)));
    64. ui->compass->setOrigin(270.0);
    65. ui->compass->setValue(0.0);
    66. }
    67.  
    68. MainWindow::~MainWindow()
    69. {
    70. delete ui;
    71. }
    72.  
    73. void MainWindow::on_sendButton_clicked()
    74. {
    75. QString packet = ui->packetLE->text(); //create packet
    76. QByteArray myDatagram = packet.toUtf8(); //convert to datagram
    77.  
    78. if(userIP == true)
    79. {
    80. udpSocket->writeDatagram(myDatagram.data(), myDatagram.size(),
    81. txIP, rxPort);
    82. }
    83. else
    84. {
    85. udpSocket->writeDatagram(myDatagram.data(), myDatagram.size(),
    86. QHostAddress::Broadcast, rxPort);
    87. }
    88. }
    89.  
    90. void MainWindow::on_configButton_clicked()
    91. {
    92. rxPort = ui->portLE->text().toInt(); //set port
    93. listenPort = ui->rxPortLE->text().toInt(); //set port to listen on
    94.  
    95. rxUdpSocket->close();
    96.  
    97. rxUdpSocket->bind(listenPort); //found in book
    98.  
    99.  
    100. if(ui->rxIPLE->text() != NULL) //if user added IP address
    101. {
    102. QString txStrIp = ui->rxIPLE->text(); //create RX IP string
    103. txIP = txStrIp; //Convert to IP Address
    104. userIP = true;
    105. }
    106. else
    107. {
    108. userIP = false;
    109. }
    110.  
    111. ui->barDepth->setMaximum(int(ui->dsbMaxDepth->value()*100));
    112. ui->plotDepth->setAxisScale(0,-1.0*ui->dsbMaxDepth->value(),0,0.5); //set y axis scale
    113.  
    114. }
    115. void MainWindow::findHostIP() //found this code online, modified it to only show IP addresses (local)
    116. {
    117. QStringList items;
    118. ui->listWidget->clear();
    119. foreach(QNetworkInterface interface, QNetworkInterface::allInterfaces())
    120. {
    121. if (interface.flags().testFlag(QNetworkInterface::IsRunning))
    122. foreach (QNetworkAddressEntry entry, interface.addressEntries())
    123. {
    124. if ( interface.hardwareAddress() != "00:00:00:00:00:00" && entry.ip().toString().contains("."))
    125. items << interface.name() + " " + entry.ip().toString();
    126. }
    127. }
    128. ui->listWidget->addItems(items);
    129. }
    130.  
    131. void MainWindow::processPendingDatagrams()
    132. {
    133. QByteArray rxDatagram;
    134. QString rxString;
    135. do
    136. {
    137. rxDatagram.resize(rxUdpSocket->pendingDatagramSize());
    138. rxUdpSocket->readDatagram(rxDatagram.data(), rxDatagram.size());
    139. }
    140. while(rxUdpSocket->hasPendingDatagrams());
    141. rxString = (tr("\"%1\"").arg(rxDatagram.data())); //turn datagram into string
    142. rxString.remove(QChar('"'), Qt::CaseInsensitive); //remove quotation marks
    143. //ui->rxPacketLabel->setText(tr("\"%1\"").arg(rxDatagram.data()));
    144. ui->rxPacketLabel->setText(rxString);
    145. QTextStream packetStream(&rxString);
    146. packetStream >> depthReadout >> voltsReadout >> ampsReadout >> tempReadout >> headingReadout >> otherReadout;
    147.  
    148. ui->lcdDepth->display(depthReadout);
    149. ui->barDepth->setValue(depthReadout * 100);
    150. ui->lcdOther->display(otherReadout);
    151. ui->lcdVolts->display(voltsReadout);
    152. ui->lcdAmps->display(ampsReadout);
    153. ui->lcdTemp->display(tempReadout);
    154. ui->leHeading->setText(QString::number(headingReadout));
    155. ui->barHeading->setValue(headingReadout*10);
    156.  
    157. //Qwt stuff
    158. myPoints.append(QPointF(0,0));
    159. myPoints[index].setX(myTime->elapsed());
    160. myPoints[index].setY(-1.0*depthReadout);
    161. index++;
    162. myCurve->setSamples(myPoints);
    163. myCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
    164. ui->plotDepth->setAxisScale(2, myTime->elapsed()-10000, myTime->elapsed(), 60000);
    165.  
    166. ui->compass->setValue(headingReadout);
    167. }
    To copy to clipboard, switch view to plain text mode 

    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)
    Qt Code:
    1. <?xml version="1.0" encoding="UTF-16"?>
    2. <DATABASE>
    3. <EXE NAME="TestCanTopside.exe" FILTER="CMI_FILTER_PRIVACY">
    4. <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" />
    5. </EXE>
    6. <EXE NAME="QtCored4.dll" FILTER="CMI_FILTER_THISFILEONLY">
    7. <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" />
    8. </EXE>
    9. <EXE NAME="kernel32.dll" FILTER="CMI_FILTER_THISFILEONLY">
    10. <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" />
    11. </EXE>
    12. </DATABASE>
    To copy to clipboard, switch view to plain text mode 

    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
    Last edited by chriskon149; 11th November 2011 at 03:15.

  2. #2
    Join Date
    Aug 2011
    Location
    California, USA
    Posts
    24
    Thanks
    4
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt Runtime Errors (Windows)

    I used Windows Task Manager to create a dump file for my compiled .exe, and it also shows that QtCored4.dll, QtGuid4.dll and QtSvgd4.dll are included in the "Modules" section. QtNetwork4.dll is also included, but the debug version is not included, unlike QtCore4.dll and QtGui4.dll, which have both release and debug versions listed. QtSvgd4.dll has only the debug version listed.

    Here's a screenshot:

    screenshot.2.jpg

  3. #3
    Join Date
    Aug 2011
    Location
    California, USA
    Posts
    24
    Thanks
    4
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt Runtime Errors (Windows)

    Okay, so I got Qwt working by doing a fresh install of the Qt SDK with Qt version 4.7.4 and Qwt version 6.0.1. I followed mpsoft's tutorial at http://www.qtcentre.org/threads/1930...eator?p=207749 to get it working. The plugin still does not work, but I can get around that by promoting QWidgets to use Qwt widgets. My .pro file for debug looks like:
    Qt Code:
    1. INCLUDEPATH += C:/qwt-6.0.1/src
    2. win32:LIBS += C:/qwt-6.0.1/lib/libqwtd.a
    3. win32:QMAKE_POST_LINK = copy /Y C:\qwt-6.0.1\lib\qwtd.dll $(DESTDIR)
    4. CONFIG +=qwt
    To copy to clipboard, switch view to plain text mode 

    My .pro for release looks like:
    Qt Code:
    1. INCLUDEPATH += C:/qwt-6.0.1/src
    2. win32:LIBS += C:/qwt-6.0.1/lib/libqwt.a
    3. win32:QMAKE_POST_LINK = copy /Y C:\qwt-6.0.1\lib\qwt.dll $(DESTDIR)
    4. CONFIG +=qwt
    To copy to clipboard, switch view to plain text mode 

    It works like a charm!

    Chris

  4. #4
    Join Date
    Feb 2008
    Posts
    2
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Qwt Runtime Errors (Windows)

    On Windows I would not recommend to mix debug and release modules.
    This causes unpredictable behaviour.

Similar Threads

  1. eXaro with Qt(runtime errors)
    By xoz in forum Qt-based Software
    Replies: 0
    Last Post: 5th June 2011, 08:31
  2. Runtime Errors Qt.4.5 + Qwt
    By giusepped in forum Qt Programming
    Replies: 2
    Last Post: 2nd April 2009, 05:41
  3. a runtime errors in QPainter::DrawPixmap(..)
    By richardander in forum Qt Programming
    Replies: 1
    Last Post: 12th February 2009, 18:46
  4. VS integration and runtime errors
    By loli in forum Qt Programming
    Replies: 2
    Last Post: 13th January 2008, 15:27
  5. Replies: 4
    Last Post: 17th January 2006, 18:46

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.