Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QPointerEvent throws error
Forum Updated to NodeBB v4.3 + New Features

QPointerEvent throws error

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
56 Posts 5 Posters 14.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.
  • C curiosity

    @JonB

    I removed it. also #include <QApplication> is not resolved by the compiler. i have to include the entire path/absolute path something like this

    #include <C:\Qt\Qt5.12.12\5.12.12\winrt_x64_msvc2017\include\QtWidgets\QApplication> which is not the right way

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #17

    @curiosity said in QPointerEvent throws error:

    also #include <QApplication> is not resolved by the compiler

    Then something is wrong with your project configuration.
    Did you rerun qmake after editing the pro file?
    It also looks like you're using Visual Studio - I never used it with Qt, but maybe you need to recreate project files after changing pro file?

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    C 1 Reply Last reply
    0
    • jsulmJ jsulm

      @curiosity said in QPointerEvent throws error:

      also #include <QApplication> is not resolved by the compiler

      Then something is wrong with your project configuration.
      Did you rerun qmake after editing the pro file?
      It also looks like you're using Visual Studio - I never used it with Qt, but maybe you need to recreate project files after changing pro file?

      C Offline
      C Offline
      curiosity
      wrote on last edited by
      #18

      @jsulm

      I am not sure from where should i run qmake in visual studio. i rebuilt the solution after deleting the build folder.

      1 Reply Last reply
      0
      • jsulmJ jsulm

        @curiosity First: this linker flag is not needed. Second: the way you added it is wrong and makes no sense.

        C Offline
        C Offline
        curiosity
        wrote on last edited by
        #19

        @jsulm @JonB

        i switched to qt creator.

        i have an error here with signals and slots

        c4385b22-d686-4bc7-aa90-9d05909b0579-image.png

        looks like i have right signals and slots. but not getting about this errorgetting about

        JonBJ jsulmJ 2 Replies Last reply
        0
        • C curiosity

          @jsulm @JonB

          i switched to qt creator.

          i have an error here with signals and slots

          c4385b22-d686-4bc7-aa90-9d05909b0579-image.png

          looks like i have right signals and slots. but not getting about this errorgetting about

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #20

          @curiosity
          Start by showing definition of the two slot functions you use.
          Is this an error only in the code completion inside Qt Creator, or do you get these errors when you actually compile?

          C 1 Reply Last reply
          0
          • C curiosity

            @jsulm @JonB

            i switched to qt creator.

            i have an error here with signals and slots

            c4385b22-d686-4bc7-aa90-9d05909b0579-image.png

            looks like i have right signals and slots. but not getting about this errorgetting about

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #21

            @curiosity You probably need to tell the compiler which overload you want to connect, see https://wiki.qt.io/New_Signal_Slot_Syntax#Overload

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            2
            • JonBJ JonB

              @curiosity
              Start by showing definition of the two slot functions you use.
              Is this an error only in the code completion inside Qt Creator, or do you get these errors when you actually compile?

              C Offline
              C Offline
              curiosity
              wrote on last edited by
              #22

              @JonB
              these are errors in QtCreator. i am yet to compile.

              jsulmJ 1 Reply Last reply
              0
              • C curiosity

                @JonB
                these are errors in QtCreator. i am yet to compile.

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #23

                @curiosity Well, then compile.
                Code model can produce false errors in QtCreator.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                C 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @curiosity Well, then compile.
                  Code model can produce false errors in QtCreator.

                  C Offline
                  C Offline
                  curiosity
                  wrote on last edited by
                  #24

                  @jsulm

                  i am trying to print the edited text(values entered by the user) onto the console. but still getting this error

                  9ac99a19-8d19-4de9-b7ac-2b2e9c495079-image.png

                  Christian EhrlicherC 1 Reply Last reply
                  0
                  • C curiosity

                    @jsulm

                    i am trying to print the edited text(values entered by the user) onto the console. but still getting this error

                    9ac99a19-8d19-4de9-b7ac-2b2e9c495079-image.png

                    Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #25
                    SIGNAL(&QLineEdit::textEdited)
                    

                    really?

                    You should read the Qt signals and slot documentation and also re-read the wiki page which @jsulm already pointed you to.

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    C 1 Reply Last reply
                    3
                    • Christian EhrlicherC Christian Ehrlicher
                      SIGNAL(&QLineEdit::textEdited)
                      

                      really?

                      You should read the Qt signals and slot documentation and also re-read the wiki page which @jsulm already pointed you to.

                      C Offline
                      C Offline
                      curiosity
                      wrote on last edited by
                      #26

                      @Christian-Ehrlicher

                      connect(echoComboBox, &QComboBox::editTextChanged(echoLineEdit),
                              this, [=](const QString &edited){qDebug() << edited;});
                      

                      i made the above change. but signal is giving error
                      "call to non static function without an object argument". editTextChanged has qstring . i tried with qsting and qlineEdit as arg. its giving same error with both

                      jsulmJ 1 Reply Last reply
                      0
                      • C curiosity

                        @Christian-Ehrlicher

                        connect(echoComboBox, &QComboBox::editTextChanged(echoLineEdit),
                                this, [=](const QString &edited){qDebug() << edited;});
                        

                        i made the above change. but signal is giving error
                        "call to non static function without an object argument". editTextChanged has qstring . i tried with qsting and qlineEdit as arg. its giving same error with both

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #27

                        @curiosity Please read the documentation! What you're doing is simply wrong and not even valid C++!
                        You do not pass parameters when calling connect! Parameters are passed to the signal when it is emitted and then from the signal to slot.

                        connect(echoComboBox, &QComboBox::editTextChanged,
                                this, [=](const QString &edited){qDebug() << edited;});
                        

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        C 1 Reply Last reply
                        3
                        • jsulmJ jsulm

                          @curiosity Please read the documentation! What you're doing is simply wrong and not even valid C++!
                          You do not pass parameters when calling connect! Parameters are passed to the signal when it is emitted and then from the signal to slot.

                          connect(echoComboBox, &QComboBox::editTextChanged,
                                  this, [=](const QString &edited){qDebug() << edited;});
                          
                          C Offline
                          C Offline
                          curiosity
                          wrote on last edited by
                          #28

                          @jsulm

                          thanks for correcting.

                          i am trying to echo the text entered by the user into QCombobox in the next line.

                          connect(echoComboBox, &QComboBox::currentTextChanged,this, &Window::onCurrentTextChanged);

                              auto text = echoComboBox->currentText();
                           passwordLineEdit = new QLineEdit;
                          
                              passwordLineEdit->setPlaceholderText("Password entered is : ");     //But this line is displayed in a new window. and password is not echoed.
                          

                          passwordLineEdit->show();

                              echoComboBox->show();
                          
                          JonBJ jsulmJ 2 Replies Last reply
                          0
                          • C curiosity

                            @jsulm

                            thanks for correcting.

                            i am trying to echo the text entered by the user into QCombobox in the next line.

                            connect(echoComboBox, &QComboBox::currentTextChanged,this, &Window::onCurrentTextChanged);

                                auto text = echoComboBox->currentText();
                             passwordLineEdit = new QLineEdit;
                            
                                passwordLineEdit->setPlaceholderText("Password entered is : ");     //But this line is displayed in a new window. and password is not echoed.
                            

                            passwordLineEdit->show();

                                echoComboBox->show();
                            
                            JonBJ Offline
                            JonBJ Offline
                            JonB
                            wrote on last edited by JonB
                            #29

                            @curiosity said in QPointerEvent throws error:

                            //But this line is displayed in a new window

                            You have created a new QLineEdit but not put it anywhere (e.g. on an existing window), so where do you expect it to go? I do not know why you are choosing to create a new QLineEdit dynamically, but give it a parent and/or place it on some widget's layout.

                            I really don't know what you are doing with a combobox."i am trying to echo the text entered by the user into QCombobox" --- what text is being entered how by user into combobox. Why in the world would you have a combobox, to choose an existing item from, if you want a user to enter a line of text for a password?

                            passwordLineEdit->setPlaceholderText("Password entered is : "); //But this line is displayed in a new window. and password is not echoed.

                            "Password is not echoed", what do you mean or expect? All you have done here is set the placeholder text of a QLineEdit to a fixed string. I see nothing in your code which perhaps copes/displays the auto text = echoComboBox->currentText(); anywhere.

                            @jsulm gave you sample code for picking up changed edited text. All you have to do is change his lambda slot to (preferably using his signal) to call a method of you own, like you show with &Window::onCurrentTextChanged, and write the code in that to access the current text or the text parameter sent from void QComboBox::editTextChanged(const QString &text) signal.

                            1 Reply Last reply
                            2
                            • C curiosity

                              @jsulm

                              thanks for correcting.

                              i am trying to echo the text entered by the user into QCombobox in the next line.

                              connect(echoComboBox, &QComboBox::currentTextChanged,this, &Window::onCurrentTextChanged);

                                  auto text = echoComboBox->currentText();
                               passwordLineEdit = new QLineEdit;
                              
                                  passwordLineEdit->setPlaceholderText("Password entered is : ");     //But this line is displayed in a new window. and password is not echoed.
                              

                              passwordLineEdit->show();

                                  echoComboBox->show();
                              
                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by
                              #30

                              @curiosity said in QPointerEvent throws error:

                              auto text = echoComboBox->currentText();
                              passwordLineEdit = new QLineEdit;

                              passwordLineEdit->setPlaceholderText("Password entered is : ");
                              

                              Please think about this code and why it can't do what you want it to do and why you get a new window.
                              @JonB gave you all needed hints.

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              C 1 Reply Last reply
                              0
                              • jsulmJ jsulm

                                @curiosity said in QPointerEvent throws error:

                                auto text = echoComboBox->currentText();
                                passwordLineEdit = new QLineEdit;

                                passwordLineEdit->setPlaceholderText("Password entered is : ");
                                

                                Please think about this code and why it can't do what you want it to do and why you get a new window.
                                @JonB gave you all needed hints.

                                C Offline
                                C Offline
                                curiosity
                                wrote on last edited by
                                #31

                                @jsulm @JonB

                                echoLayout->addWidget(passwordLabel, 2, 0);
                                echoLayout->addWidget(passwordLineEdit, 2, 1, 2, 3 );
                                this is added to the grid layout

                                QObject::connect(echoComboBox, &QComboBox::editTextChanged, this, [=](const QString &text) {
                                Window::onCurrentTextChanged(text);
                                });

                                void onCurrentTextChanged(const QString &text)
                                {
                                    passwordLineEdit->setPlaceholderText("Password entered is : ");
                                    passwordLineEdit->setText(text);  //Is this the right way to set the text   received from above signal. }
                                

                                value entered is still not reflecting

                                jsulmJ C JonBJ 3 Replies Last reply
                                0
                                • C curiosity

                                  @jsulm @JonB

                                  echoLayout->addWidget(passwordLabel, 2, 0);
                                  echoLayout->addWidget(passwordLineEdit, 2, 1, 2, 3 );
                                  this is added to the grid layout

                                  QObject::connect(echoComboBox, &QComboBox::editTextChanged, this, [=](const QString &text) {
                                  Window::onCurrentTextChanged(text);
                                  });

                                  void onCurrentTextChanged(const QString &text)
                                  {
                                      passwordLineEdit->setPlaceholderText("Password entered is : ");
                                      passwordLineEdit->setText(text);  //Is this the right way to set the text   received from above signal. }
                                  

                                  value entered is still not reflecting

                                  jsulmJ Offline
                                  jsulmJ Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #32

                                  @curiosity said in QPointerEvent throws error:

                                  QObject::connect(echoComboBox, &QComboBox::editTextChanged, this, [=](const QString &text) {
                                  Window::onCurrentTextChanged(text);
                                  });

                                  There is no need for a lambda, just connect onCurrentTextChanged directly to the signal.

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  0
                                  • C curiosity

                                    @jsulm @JonB

                                    echoLayout->addWidget(passwordLabel, 2, 0);
                                    echoLayout->addWidget(passwordLineEdit, 2, 1, 2, 3 );
                                    this is added to the grid layout

                                    QObject::connect(echoComboBox, &QComboBox::editTextChanged, this, [=](const QString &text) {
                                    Window::onCurrentTextChanged(text);
                                    });

                                    void onCurrentTextChanged(const QString &text)
                                    {
                                        passwordLineEdit->setPlaceholderText("Password entered is : ");
                                        passwordLineEdit->setText(text);  //Is this the right way to set the text   received from above signal. }
                                    

                                    value entered is still not reflecting

                                    C Offline
                                    C Offline
                                    curiosity
                                    wrote on last edited by
                                    #33

                                    @curiosity
                                    c1211f47-d3fc-4cf7-be62-2ce6511bf141-image.png

                                    1 Reply Last reply
                                    0
                                    • C curiosity

                                      @jsulm @JonB

                                      echoLayout->addWidget(passwordLabel, 2, 0);
                                      echoLayout->addWidget(passwordLineEdit, 2, 1, 2, 3 );
                                      this is added to the grid layout

                                      QObject::connect(echoComboBox, &QComboBox::editTextChanged, this, [=](const QString &text) {
                                      Window::onCurrentTextChanged(text);
                                      });

                                      void onCurrentTextChanged(const QString &text)
                                      {
                                          passwordLineEdit->setPlaceholderText("Password entered is : ");
                                          passwordLineEdit->setText(text);  //Is this the right way to set the text   received from above signal. }
                                      

                                      value entered is still not reflecting

                                      JonBJ Offline
                                      JonBJ Offline
                                      JonB
                                      wrote on last edited by
                                      #34

                                      @curiosity said in QPointerEvent throws error:

                                      value entered is still not reflecting

                                      Not sure where you are at now. Yes, calling passwordLineEdit->setText(text); should set the text from the string. Check what is in the string. Check you are getting the signal by putting a qDebug() or something in the slot so that you know it is being called.

                                      C 1 Reply Last reply
                                      1
                                      • JonBJ JonB

                                        @curiosity said in QPointerEvent throws error:

                                        value entered is still not reflecting

                                        Not sure where you are at now. Yes, calling passwordLineEdit->setText(text); should set the text from the string. Check what is in the string. Check you are getting the signal by putting a qDebug() or something in the slot so that you know it is being called.

                                        C Offline
                                        C Offline
                                        curiosity
                                        wrote on last edited by
                                        #35

                                        @JonB
                                        Ialready checked by planting a breakpoint in onCurrentTextChanged . on running and entering the text in the place holder i was expecting to hit the breakpoint, but it didnt hit.
                                        this is my connect statement

                                        connect(echoComboBox,&QComboBox::editTextChanged, this, &Window::onCurrentTextChanged);

                                        void onCurrentTextChanged(const QString &text)
                                        {
                                            qDebug() << QString(" entered text is ")<<  text;
                                        

                                        //nothing is printed here in the application tab in qtcreator. it is not even hitting this breakpoint
                                        passwordLineEdit->setPlaceholderText("Password entered is : ");
                                        passwordLineEdit->setText(text);
                                        passwordLineEdit->show();
                                        passwordLineEdit->setEchoMode(QLineEdit::PasswordEchoOnEdit);

                                        }
                                        
                                        Christian EhrlicherC 1 Reply Last reply
                                        0
                                        • C curiosity

                                          @JonB
                                          Ialready checked by planting a breakpoint in onCurrentTextChanged . on running and entering the text in the place holder i was expecting to hit the breakpoint, but it didnt hit.
                                          this is my connect statement

                                          connect(echoComboBox,&QComboBox::editTextChanged, this, &Window::onCurrentTextChanged);

                                          void onCurrentTextChanged(const QString &text)
                                          {
                                              qDebug() << QString(" entered text is ")<<  text;
                                          

                                          //nothing is printed here in the application tab in qtcreator. it is not even hitting this breakpoint
                                          passwordLineEdit->setPlaceholderText("Password entered is : ");
                                          passwordLineEdit->setText(text);
                                          passwordLineEdit->show();
                                          passwordLineEdit->setEchoMode(QLineEdit::PasswordEchoOnEdit);

                                          }
                                          
                                          Christian EhrlicherC Offline
                                          Christian EhrlicherC Offline
                                          Christian Ehrlicher
                                          Lifetime Qt Champion
                                          wrote on last edited by Christian Ehrlicher
                                          #36

                                          @curiosity said in QPointerEvent throws error:

                                          void onCurrentTextChanged(const QString &text)...

                                          This is a free function... How does this even compile?

                                          Please provide your full relevant code which actually compiles.

                                          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                          Visit the Qt Academy at https://academy.qt.io/catalog

                                          C 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