Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [Moved] Trying to access QTextEdit instance via Ui pointer within QTimer-callback-function leads to SIGSEGV

    General and Desktop
    3
    4
    2711
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      wumpus last edited by

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

      1 Reply Last reply Reply Quote 0
      • G
        goetz last edited by

        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.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply Reply Quote 0
        • G
          giesbert last edited by

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

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply Reply Quote 0
          • W
            wumpus last edited by

            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

            1 Reply Last reply Reply Quote 0
            • First post
              Last post