Saturday, July 5th 2008, 6:38am UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Thursday, May 1st 2008, 2:40pm

Windows Error Message upon Exit

Hello,

I am new to QT and relatively new to c++.

I am trying to write a widget wich displays a number of QLineEdits in a grid layout.
The numberof cells and the aspect ratio are the arguments of the constructor.
Here's what I've written:
!------------------------------------------------------------------------------------------------
#ifndef TEXT_NETVIEWER_H
#define TEXT_NETVIEWER_H

#include <QWidget.h>
#include "QLineEdit.h"


class text_netviewer : public QWidget
{
public:
text_netviewer(int in, int num,QWidget *p=0);
QLineEdit *field;
virtual ~text_netviewer();
protected:
private:
};

#endif // TEXT_NETVIEWER_H
!-------------------------------------------------------------------------------------------------
#include "text_netviewer.h"

#include <cmath>
#include <iostream>
#include "QGridLayout.h"
using namespace std;



text_netviewer::text_netviewer(int in, int n,QWidget *p)
:QWidget(p)
{
int rows=int(ceil(double(n)/double(in)));
QGridLayout *grid=new QGridLayout(this);
field=new QLineEdit[rows*in];

int c=0;
for(int i=rows;i>0;--i)
{
for(int j=0;j<in;j++)
{
grid->addWidget(&field

C/C++ Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
,i,j);<br />
                c++;<br />
        }<br />
<br />
    }<br />
<br />
}<br />
<br />
text_netviewer::~text_netviewer()<br />
{<br />
    //dtor<br />
}<br />
!-------------------------------------------------------------------------------------------------<br />
<br />
This seems to work fine at first. It compiles with no complaints and shows the expected behaviour when run. <br />
When the window is closed however,  Windows returns a &quot;the program encountered an error and had to be closed. send error report?&quot; message.<br />
<br />
I use QT 4.3.4 on XP(SP2) with mingw.<br />
<br />
I have no clue why this is. I am beginning to think that I am doing something fundamentally wrong, but can't see what.<br />
<br />
Any help appreciated.<br />
<br />
thans,<br />
<br />
t.
  • Go to the top of the page

2

Saturday, May 3rd 2008, 2:25am

RE: Windows Error Message upon Exit

it looks like field and grid are not being destroyed. Destroy these and try again
  • Go to the top of the page

Rate this thread