Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Moved] Trying to access QTextEdit instance via Ui pointer within QTimer-callback-function leads to SIGSEGV
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.9k Views
  • 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 Offline
    W Offline
    wumpus
    wrote on last edited by
    #1

    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
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      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
      0
      • G Offline
        G Offline
        giesbert
        wrote on last edited by
        #3

        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
        0
        • W Offline
          W Offline
          wumpus
          wrote on last edited by
          #4

          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
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved