[SOLVED] My Qt class and QTableWidget
-
Signal name :
SIGSEGV
Signal meaning :
Segmentation faultOn a first call to QTableWidget (function clearContents())
-
so where's the code for that? I don't see any calls in constructor
-
Of what type is member table?
Where exactly does the crash happen?PS:
While there is no official registry for class name prefixes, it is common sense and highly recommended to not use Q for your own classes, as this is the prefix used by Qt itself. So, to not clash with future Qt versions, you should rename QTemplate to something different. -
[quote author="Kxyu" date="1321119486"]so where's the code for that? I don't see any calls in constructor[/quote]
It in start() function:
@void QTemplate::start(int m, int c) {
table->clear();
msec = m;
cells = c;
emit started();
}@[quote author="Volker" date="1321119539"]Of what type is member table?
Where exactly does the crash happen?PS:
While there is no official registry for class name prefixes, it is common sense and highly recommended to not use Q for your own classes, as this is the prefix used by Qt itself. So, to not clash with future Qt versions, you should rename QTemplate to something different.[/quote]Declaration of 'table':
@QTableWidget* table;@Error on first call to 'table'
-
Check that table is not NULL.
-
Ok. Now I don't see where start() is called. Looks like table points to nowhere.
-
[quote author="Volker" date="1321119951"]Check that table is not NULL.[/quote]
In constructor:
@table = &wgt;@
It can't be NULL.[quote author="Kxyu" date="1321120089"]Ok. Now I don't see where start() is called. Looks like table points to nowhere. [/quote]
In MainWindow:
@void MainWindow::startTemplate()
{
term->start(1200,3);
}@ -
i guess we need only one piece of that puzzle - the code of MainWindow constructor
-
[quote author="Kxyu" date="1321120692"]i guess we need only one piece of that puzzle - the code of MainWindow constructor[/quote]
Please:
@MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
classicTimer = new QTimer(this);
term = new QTemplate(*ui->templates);
setWindowIcon(QIcon(":/favicon.png"));
setGeometry(150,100,960,670);
}@@#ifdef ru_RU
"Так что там с пазлом?"
#endif@ -
Ok, we're almost there) What we need to see is the relation between
@term = new QTemplate(*ui->templates);@and
@table->clear();@
so I 'll ask you to show the place where startTemplate is called, the place where that place is called and so on. So you'd better show us the whole code)
@#ifdef ru_RU
"Разберемся)"
#endif@ -
[quote author="Kxyu" date="1321121317"]Ok, we're almost there) What we need to see is the relation between
@term = new QTemplate(*ui->templates);@and
@table->clear();@
so I 'll ask you to show the place where startTemplate is called, the place where that place is called and so on. So you'd better show us the whole code)
@#ifdef ru_RU
"Разберемся)"
#endif@
[/quote]Can you chat outside DevNet?
All my contacts in profile.
-
If you want your questions to be answered in russian you can post them "here":http://developer.qt.nokia.com/forums/viewforum/29/
-
OK. I can give you whole my MainWindow code.
@#include "mainwindow.h"
#include "ui_mainwindow.h"MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
classicTimer = new QTimer(this);
term = new QTemplate(*ui->templates);
setWindowIcon(QIcon(":/favicon.png"));
setGeometry(150,100,960,670);
// *** Connects of TEMPLATE *** //
connect(ui->templateStart,SIGNAL(clicked()),this,SLOT(startTemplate()));
// *** END connects of TEMPLATE *** //
}MainWindow::~MainWindow()
{
delete ui;
}void MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}void MainWindow::startTemplate()
{
term->start(1200,3);
}@ -
The code does not look fishy from what we know. Did you try to compile the program in debug mode and run it through the debugger already? This way you know where it bails out.
-
Thanks everybody. I found error and fixed it, so I am closing topic.
-
So, could you please post your solution? It could help others with similar issues.
BTW: topics are closed by moderators, not by users ;-) But you are very much invited to mark your topic as [Solved] by clicking the small edit link next to the first posting in the topic. That allows you to edit the title of the topic.