a crazy problem~~~who can help me : (
I write a simple qt program.
when I run the program, there is not any error in release mode.
However, in debug mode, it jumps a warning dialog and the program crash. Shows as follows:
Windows has triggered a breakpoint in QT2.exe.
This may be due to a corruption of the heap, which indicates a bug in QT2.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while QT2.exe has focus.
The output window may have more diagnostic information.
I cost the whole afternoon to slove this problem and still cann't deal with the problem.
Thank you...
Re: a crazy problem~~~who can help me : (
There are two problems:
1. You simply cry for help in the title of your post. Better give a short description of your problem. "Please help" is not usefull to those who might give help.
2. If it really is a simple Qt application, why didn't you provide the code? Our capabilities in clairvoyance are very limited.
Re: a crazy problem~~~who can help me : (
Quote:
Originally Posted by
Boron
There are two problems:
1. You simply cry for help in the title of your post. Better give a short description of your problem. "Please help" is not usefull to those who might give help.
2. If it really is a simple Qt application, why didn't you provide the code? Our capabilities in clairvoyance are very limited.
Sorry, English is not my native language.
I am student in Department of Computer and Science from china.
I am new comer.
If I made mistakes, please forgive me:)
The follows are my code.
//main.cpp
Code:
#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")
#include <Qt\QApplication.h>
#include "ByteConverterDialog.h"
int main(int argc, char *argv[])
{
ByteConverterDialog bc;
bc.setAttribute(Qt::WA_QuitOnClose);
bc.show();
return a.exec();
};
//ByteConverterDialog.h
Code:
#ifndef BYTECONVERTERDIALOG_H
#define BYTECONVERTERDIALOG_H
#include <QtGui\QDialog.h>
class ByteConverterDialog
:public QDialog{
Q_OBJECT
public:
ByteConverterDialog();
private:
private:
void decChanged(const QString&);
void hexChanged(const QString&);
void binChanged(const QString&);
};
#endif
//ByteConverterDialog.cpp
Code:
#include "ByteConverterDialog.h"
#include <QtGui/QLabel.h>
#include <QtGui/QLineEdit.h>
#include <QtGui/QPushButton.h>
#include <QtGui/QVBoxLayout.h>
#include <QtGui/QHBoxLayout.h>
#include <QtGui/QGridLayout.h>
#include <QtGui/QIntValidator>
ByteConverterDialog::ByteConverterDialog()
{
mainLayout->addLayout(editLayout);
mainLayout->addStretch();
mainLayout->addLayout(buttonLayout);
editLayout->addWidget(decLabel,0,0);
editLayout->addWidget(decEdit,0,1);
editLayout->addWidget(hexLabel,1,0);
editLayout->addWidget(hexEdit,1,1);
editLayout->addWidget(binLabel,2,0);
editLayout->addWidget(binEdit,2,1);
buttonLayout->addStretch();
buttonLayout->addWidget(exitButton);
exitButton->setDefault(true);
decEdit->setValidator(decValidator);
hexEdit->setValidator(hexValidator);
binEdit->setValidator(binValidator);
setWindowTitle(tr("Byte Converter"));
QObject::connect(exitButton,
SIGNAL(clicked
()),
this,
SLOT(accept
()));
QObject::connect(decEdit,
SIGNAL(textChanged
(const QString
&)),
this,
SLOT(decChanged
(const QString
&)));
QObject::connect(hexEdit,
SIGNAL(textChanged
(const QString
&)),
this,
SLOT(hexChanged
(const QString
&)));
QObject::connect(binEdit,
SIGNAL(textChanged
(const QString
&)),
this,
SLOT(binChanged
(const QString
&)));
}
void ByteConverterDialog::decChanged(const QString& newValue)
{
bool ok;
int num=newValue.toInt(&ok);
if(ok)
{
hexEdit
->setText
(QString::number(num,
16));
binEdit
->setText
(QString::number(num,
2));
}
else
{
hexEdit->setText("");
binEdit->setText("");
}
}
void ByteConverterDialog::hexChanged(const QString& newValue)
{
bool ok;
int num=newValue.toInt(&ok,16);
if(ok)
{
decEdit
->setText
(QString::number(num
));
binEdit
->setText
(QString::number(num,
2));
}
else
{
decEdit->setText("");
binEdit->setText("");
}
}
void ByteConverterDialog::binChanged(const QString& newValue)
{
bool ok;
int num=newValue.toInt(&ok,2);
if(ok)
{
decEdit
->setText
(QString::number(num
));
hexEdit
->setText
(QString::number(num,
16));
}
else
{
decEdit->setText("");
hexEdit->setText("");
}
}
Re: a crazy problem~~~who can help me : (
the error appears in this code
Code:
...
ByteConverterDialog bc;
bc.setAttribute(Qt::WA_QuitOnClose);
bc.show();
...
if you want to use this flag then you need to allocate ByteConverterDialog using operator new or simply comment 'setAttribute' call and rebuild project.
EDITED: sorry, I thought that you use WA_DeleteOnClose. :)
PS. to moderator: could you delete my previous post?
Re: a crazy problem~~~who can help me : (
Tanks, I have already solved this problem:)