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. I have strange behaviour while using an array of QTextEdit widgets.
Forum Updated to NodeBB v4.3 + New Features

I have strange behaviour while using an array of QTextEdit widgets.

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 275 Views 1 Watching
  • 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.
  • E Offline
    E Offline
    emp1953
    wrote on 20 Apr 2022, 16:39 last edited by
    #1

    I have implemented an array of QTextEdit boxes as follows:

    QTextEdit* ntr_array[45];

    ntr_array[1] = ui->textEdit_1;

    I have a std::vector std::stringmyvector containing 45 text words of type std::string

    Then I do this

    Qstring tempstr = QString::fromStdString(myvector[1]);
    ntr_array[1]->setText(tempstr);

    This compiles and when executed will seg fault at the last line: ntr_array[1]->setText(tempstr);

    I've tried substituting
    ui->textEdit_1->setText(tempstr);

    It still seg faults on this line.

    I am using QT 4.8
    QtCreator 3.2.2
    on linux Fedora.

    Thanks for any help

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mpergand
      wrote on 20 Apr 2022, 17:39 last edited by
      #2

      Run the debugger !
      However, ui->textEdit_1; looks like an invalid pointer ...

      1 Reply Last reply
      1
      • E Offline
        E Offline
        emp1953
        wrote on 20 Apr 2022, 18:47 last edited by
        #3

        The editor auto finishes the ui->textEdit_1 line so the editor thinks it is valid. What should I look for in the debugger when I set the breakpoint at the line it seg faults at and it stops there??

        J 1 Reply Last reply 20 Apr 2022, 19:16
        0
        • E emp1953
          20 Apr 2022, 18:47

          The editor auto finishes the ui->textEdit_1 line so the editor thinks it is valid. What should I look for in the debugger when I set the breakpoint at the line it seg faults at and it stops there??

          J Offline
          J Offline
          JonB
          wrote on 20 Apr 2022, 19:16 last edited by JonB
          #4

          @emp1953
          You could try putting ui->textEdit_1 into the debugger's Watch window and having a look at what seems to be in it.

          I assume you created that in the designer. Have you done the ui->setupUi() call in your code? Make sure you have done a full rebuild.

          1 Reply Last reply
          2
          • E Offline
            E Offline
            emp1953
            wrote on 20 Apr 2022, 19:59 last edited by
            #5

            Yes ui->setup() happens
            nutr[2] has a big hex number that looks like a pointer.

            I did a qmake on the .pro file and got a Makefile.
            Did a 'make clean; make' now all is good. Apparently the clean function in qtCreator doesn't really function as advertised

            Thanks for the help

            1 Reply Last reply
            0

            5/5

            20 Apr 2022, 19:59

            • Login

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