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. [SOLVED] textEdit not letting me access any of its functions
Qt 6.11 is out! See what's new in the release blog

[SOLVED] textEdit not letting me access any of its functions

Scheduled Pinned Locked Moved General and Desktop
19 Posts 4 Posters 6.9k 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.
  • R Offline
    R Offline
    rizoritis
    wrote on last edited by
    #8

    Yes, I did clean the project and run qmake. Sorry, I forgot to mention that in my last post.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rizoritis
      wrote on last edited by
      #9

      Just to clarify, nothing in my textEdit ("programTextEdit") works. I get the same error when I try accessing anything in the ui.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rizoritis
        wrote on last edited by
        #10

        I played around. If I put the following lines:

        @ ui->programTextEdit->setPlainText(line);
        ui->runButton->setEnabled(true);
        ui->pauseButton->setEnabled(true);@

        in the constructor, I get no build error. The errors only come up if I throw it in a separate function within my source file. Why is that?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #11

          Is your separate function a member of BasicGui ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rizoritis
            wrote on last edited by
            #12

            Yup. See below (displayProgram):

            @#ifndef BASICGUI_H
            #define BASICGUI_H

            #include <QMainWindow>
            #include <QtGui>
            #include <QtCore>

            namespace Ui {
            class BasicGui;
            }

            class BasicGui : public QMainWindow
            {
            Q_OBJECT

            public:
            explicit BasicGui(QWidget *parent = 0);
            ~BasicGui();
            static void displayProgram(QString);

            private slots:
            void on_selectProgramButton_clicked();
            void on_loadProgramButton_clicked();

            private:
            Ui::BasicGui *ui;

            };

            #endif // BASICGUI_H@

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #13

              So you are trying to modify a private class member from a static function ?

              That's not allowed

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • R Offline
                R Offline
                rizoritis
                wrote on last edited by
                #14

                [quote author="SGaist" date="1368717950"]So you are trying to modify a private class member from a static function ?

                That's not allowed[/quote]

                OK, I made the function non-static, but am now getting a function saying "error: C2352: 'BasicGui::displayProgram' : illegal call of non-static member function" when trying to call the function from another class/file with the following code:

                @ BasicGui::displayProgram(aPath);@

                1 Reply Last reply
                0
                • raven-worxR Offline
                  raven-worxR Offline
                  raven-worx
                  Moderators
                  wrote on last edited by
                  #15

                  @
                  ui->displayProgram(aPath);
                  @

                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                  If you have a question please use the forum so others can benefit from the solution in the future

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    rizoritis
                    wrote on last edited by
                    #16

                    [quote author="raven-worx" date="1368719638"]@
                    ui->displayProgram(aPath);
                    @[/quote]

                    displayProgram() is from another class (Ui::BasicGui) so when I do that it says that displayProgram is not a member of the class that I am making the call in (which in this case is called Ui::SelectFile).

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      rizoritis
                      wrote on last edited by
                      #17

                      I got it to work. I didn't make an object of BasicGui in my SelectFile class. I did the following for it to work:

                      @public:
                      explicit SelectFile(QWidget *parent = 0);
                      ~SelectFile();
                      BasicGui *basicgui;
                      @

                      Then I made a call to basicgui->displayProgram()

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #18

                        Your code looks like it's getting messy. You are starting to have pointers to objects not directly related to those you are using.

                        May I suggest reading some of the examples from the Qt documentation ?

                        Typically updating your line edit content from another widget should be done using signals and slots (Unless I misunderstood your code). Or if SelectFile is a dialog to select a file (like the name suggests) why not use QFileDialog from BasicGui and directly update the line edit ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • R Offline
                          R Offline
                          rizoritis
                          wrote on last edited by
                          #19

                          OK. I will do some HW. Thanks!

                          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