Important: Please read the Qt Code of Conduct -

[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) :
    ui(new Ui::WASABIWindow)

    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() {
    This "updateGUI(bool force = false)" is a private member function of my WASABIWindow.
    In this function, then, the following line gives me a SIGSEGV:

    and it is totally irrelevant, what I try to call on textEditPAD. It always fails.
    Even this
    @ if (!ui){

    Did not help.

    What is the magic about this Ui-concept?
    Please help, I am desperate..

  • In general it should work this way, and it does in all my projects. Did you try to rebuild (clean & compile) the whole project. Sometimes this solves weird errors.

    If that doesn't work, a small yet complete testcase that we can build ourselfs would help.

  • you should not call your slot update! update is slot inside QWidget. Perhaps that has some influence here...

  • 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:
    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,

Log in to reply