Results 1 to 5 of 5

Thread: a crazy problem~~~who can help me : (

  1. #1
    Join Date
    Jan 2009
    Location
    China
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question 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...

  2. #2
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

  3. #3
    Join Date
    Jan 2009
    Location
    China
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: a crazy problem~~~who can help me : (

    Quote Originally Posted by Boron View Post
    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
    Qt Code:
    1. #pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")
    2. #include <Qt\QApplication.h>
    3. #include "ByteConverterDialog.h"
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7.  
    8. ByteConverterDialog bc;
    9. bc.setAttribute(Qt::WA_QuitOnClose);
    10. bc.show();
    11.  
    12. return a.exec();
    13. };
    To copy to clipboard, switch view to plain text mode 

    //ByteConverterDialog.h
    Qt Code:
    1. #ifndef BYTECONVERTERDIALOG_H
    2. #define BYTECONVERTERDIALOG_H
    3.  
    4. #include <QtGui\QDialog.h>
    5.  
    6. class QLineEdit;
    7.  
    8. class ByteConverterDialog:public QDialog
    9. {
    10. Q_OBJECT
    11.  
    12. public:
    13. ByteConverterDialog();
    14.  
    15. private:
    16. QLineEdit* decEdit;
    17. QLineEdit* hexEdit;
    18. QLineEdit* binEdit;
    19.  
    20. private:
    21. void decChanged(const QString&);
    22. void hexChanged(const QString&);
    23. void binChanged(const QString&);
    24. };
    25.  
    26. #endif
    To copy to clipboard, switch view to plain text mode 

    //ByteConverterDialog.cpp
    Qt Code:
    1. #include "ByteConverterDialog.h"
    2. #include <QtGui/QLabel.h>
    3. #include <QtGui/QLineEdit.h>
    4. #include <QtGui/QPushButton.h>
    5. #include <QtGui/QVBoxLayout.h>
    6. #include <QtGui/QHBoxLayout.h>
    7. #include <QtGui/QGridLayout.h>
    8. #include <QtGui/QIntValidator>
    9.  
    10. ByteConverterDialog::ByteConverterDialog()
    11. {
    12. QVBoxLayout* mainLayout=new QVBoxLayout(this);
    13. QGridLayout* editLayout=new QGridLayout;
    14. QHBoxLayout* buttonLayout=new QHBoxLayout;
    15.  
    16. mainLayout->addLayout(editLayout);
    17. mainLayout->addStretch();
    18. mainLayout->addLayout(buttonLayout);
    19.  
    20. QLabel* decLabel=new QLabel(tr("Decimal"));
    21. QLabel* hexLabel=new QLabel(tr("Hex"));
    22. QLabel* binLabel=new QLabel(tr("Binary"));
    23.  
    24. decEdit=new QLineEdit;
    25. hexEdit=new QLineEdit;
    26. binEdit=new QLineEdit;
    27.  
    28. editLayout->addWidget(decLabel,0,0);
    29. editLayout->addWidget(decEdit,0,1);
    30. editLayout->addWidget(hexLabel,1,0);
    31. editLayout->addWidget(hexEdit,1,1);
    32. editLayout->addWidget(binLabel,2,0);
    33. editLayout->addWidget(binEdit,2,1);
    34.  
    35. QPushButton* exitButton=new QPushButton(tr("Quit"));
    36.  
    37. buttonLayout->addStretch();
    38. buttonLayout->addWidget(exitButton);
    39.  
    40. exitButton->setDefault(true);
    41.  
    42. QIntValidator* decValidator=new QIntValidator(0,255,decEdit);
    43. decEdit->setValidator(decValidator);
    44.  
    45. QRegExpValidator* hexValidator=new QRegExpValidator(QRegExp("[0-9A-Fa-z]{1,2}"),hexEdit);
    46. hexEdit->setValidator(hexValidator);
    47.  
    48. QRegExpValidator* binValidator=new QRegExpValidator(QRegExp("[01]{1,8}"),binEdit);
    49. binEdit->setValidator(binValidator);
    50.  
    51. setWindowTitle(tr("Byte Converter"));
    52.  
    53. QObject::connect(exitButton,SIGNAL(clicked()),this,SLOT(accept()));
    54.  
    55. QObject::connect(decEdit,SIGNAL(textChanged(const QString&)),this,SLOT(decChanged(const QString&)));
    56. QObject::connect(hexEdit,SIGNAL(textChanged(const QString&)),this,SLOT(hexChanged(const QString&)));
    57. QObject::connect(binEdit,SIGNAL(textChanged(const QString&)),this,SLOT(binChanged(const QString&)));
    58.  
    59. }
    60.  
    61. void ByteConverterDialog::decChanged(const QString& newValue)
    62. {
    63. bool ok;
    64. int num=newValue.toInt(&ok);
    65. if(ok)
    66. {
    67. hexEdit->setText(QString::number(num,16));
    68. binEdit->setText(QString::number(num,2));
    69. }
    70. else
    71. {
    72. hexEdit->setText("");
    73. binEdit->setText("");
    74. }
    75. }
    76.  
    77. void ByteConverterDialog::hexChanged(const QString& newValue)
    78. {
    79. bool ok;
    80. int num=newValue.toInt(&ok,16);
    81. if(ok)
    82. {
    83. decEdit->setText(QString::number(num));
    84. binEdit->setText(QString::number(num,2));
    85. }
    86. else
    87. {
    88. decEdit->setText("");
    89. binEdit->setText("");
    90. }
    91. }
    92.  
    93. void ByteConverterDialog::binChanged(const QString& newValue)
    94. {
    95. bool ok;
    96. int num=newValue.toInt(&ok,2);
    97. if(ok)
    98. {
    99. decEdit->setText(QString::number(num));
    100. hexEdit->setText(QString::number(num,16));
    101. }
    102. else
    103. {
    104. decEdit->setText("");
    105. hexEdit->setText("");
    106. }
    107. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 2nd January 2009 at 15:48.

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: a crazy problem~~~who can help me : (

    the error appears in this code
    Qt Code:
    1. ...
    2. ByteConverterDialog bc;
    3. bc.setAttribute(Qt::WA_QuitOnClose);
    4. bc.show();
    5. ...
    To copy to clipboard, switch view to plain text mode 
    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?
    Last edited by spirit; 2nd January 2009 at 14:11.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. The following user says thank you to spirit for this useful post:

    sunking_426 (2nd January 2009)

  6. #5
    Join Date
    Jan 2009
    Location
    China
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: a crazy problem~~~who can help me : (

    Tanks, I have already solved this problem

Similar Threads

  1. Crazy over the QGraphicsScene/Item
    By Morea in forum Qt Programming
    Replies: 6
    Last Post: 20th November 2006, 09:18

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.