[Moved] Trying to access QTextEdit instance via Ui pointer within QTimer-callback-function leads to SIGSEGV
-
Hi,
my situation is as follows:
I'm using QtCreator to design my GUI and thus have a main window like this:
@WASABIWindow::WASABIWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::WASABIWindow)
{
ui->setupUi(this);
setCentralWidget(ui->tabWidgetMain);@In the end of the constructor I instantiate a QTimer *timer; like this:
@timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(2000); // 50Hz@"update()" is defined as a "private slot" in the header and within that function I am calling another function "updateGUI" (among other things). Liek here:
@void WASABIWindow::update() {
updateGUI();
}@
This "updateGUI(bool force = false)" is a private member function of my WASABIWindow.
In this function, then, the following line gives me a SIGSEGV:
@ui->textEditPAD->acceptDrops();@and it is totally irrelevant, what I try to call on textEditPAD. It always fails.
Even this
@ if (!ui){
return;
}@Did not help.
What is the magic about this Ui-concept?
Please help, I am desperate.. -
-
Hi there,
thanks for the tipp to build a test case. Indeed, a similar application with only one QTextEdit runs just fine. After two more hours of debugging I found this to be the problem:
@setCentralWidget(ui->tabWidgetMain);@
Due to this (experimentally induced) line of code, the texEditPAD was not visible during runtime! (Just the tabWidget is visible, nothing else.)Thus, any call to any function of that TextEdit was doomed to fail.
After removing the "setCentralWidget" line, it works fine.
Thanks for your replies,
wumpus