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

    C 1 Reply Last reply
    0
    • Christian EhrlicherC Christian Ehrlicher

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

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

      @Christian-Ehrlicher
      but i am using this as a slot. Please check the connect statement

      Christian EhrlicherC 1 Reply Last reply
      0
      • C curiosity

        @Christian-Ehrlicher
        but i am using this as a slot. Please check the connect statement

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

        void MainWindow::onCurrentTextChanged() and void onCurrentTextChanged() are two different functions. Provide your full code including the header.

        C 1 Reply Last reply
        1
        • Christian EhrlicherC Christian Ehrlicher

          void MainWindow::onCurrentTextChanged() and void onCurrentTextChanged() are two different functions. Provide your full code including the header.

          C Offline
          C Offline
          curiosity
          wrote on last edited by
          #39
          This post is deleted!
          Christian EhrlicherC 1 Reply Last reply
          0
          • C curiosity

            This post is deleted!

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

            And now please format your code with the code (</>) tags so it is readable for others.
            Your header does not match the source - this does not compile. And then you have a local variable echoLabel but connect the member later on...

            C 1 Reply Last reply
            0
            • Christian EhrlicherC Christian Ehrlicher

              And now please format your code with the code (</>) tags so it is readable for others.
              Your header does not match the source - this does not compile. And then you have a local variable echoLabel but connect the member later on...

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

              @Christian-Ehrlicher
              //NewWidget.cpp

              #include "NewWidget.h"
              #include <iostream>
              using namespace std;
              
              #include <QComboBox>
              #include <QGridLayout>
              #include <QGroupBox>
              #include <QLabel>
              #include <QLineEdit>
              #include <QtWidgets>
              
              
              Window::Window(QWidget *parent) QWidget(parent)
              {
                  QGroupBox *echoGroup = new QGroupBox(tr("Echo"));
              
              QLabel *echoLabel = new QLabel(tr("Mode:"));
              QComboBox *echoComboBox = new QComboBox;
              echoComboBox->addItem(tr("Normal"));
              echoComboBox->addItem(tr("Password"));
              echoComboBox->addItem(tr("PasswordEchoOnEdit"));
              echoComboBox->addItem(tr("No Echo"));
              
              
              echoLineEdit = new QLineEdit;
              echoLineEdit->setPlaceholderText("Placeholder Text");
              
              QLabel *passwordLabel = new QLabel(tr("Password entered is :"));
              passwordLineEdit = new QLineEdit;
              
              QGroupBox *validatorGroup = new QGroupBox(tr("Validator"));
              
              QLabel *validatorLabel = new QLabel(tr("Type:"));
              QComboBox *validatorComboBox = new QComboBox;
              validatorComboBox->addItem(tr("No validator"));
              validatorComboBox->addItem(tr("Integer validator"));
              validatorComboBox->addItem(tr("Double validator"));
              
              validatorLineEdit = new QLineEdit;
              validatorLineEdit->setPlaceholderText("Placeholder Text");
              
              QGroupBox *alignmentGroup = new QGroupBox(tr("Alignment"));
              
              QLabel *alignmentLabel = new QLabel(tr("Type:"));
              QComboBox *alignmentComboBox = new QComboBox;
              alignmentComboBox->addItem(tr("Left"));
              alignmentComboBox->addItem(tr("Centered"));
              alignmentComboBox->addItem(tr("Right"));
              
              alignmentLineEdit = new QLineEdit;
              alignmentLineEdit->setPlaceholderText("Placeholder Text");/>
              
              connect(echoComboBox,&QComboBox::editTextChanged, this, &Window::onCurrentTextChanged);
              
              connect(validatorComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated),this, &Window::validatorChanged);
              connect(alignmentComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &Window::alignmentChanged);
              
              QGridLayout *echoLayout = new QGridLayout;
              echoLayout->addWidget(echoLabel, 0, 0);
              echoLayout->addWidget(echoComboBox, 0, 1, Qt::AlignLeft);
              echoLayout->addWidget(echoLineEdit, 1, 0, 1, 2);
              echoLayout->addWidget(passwordLabel, 2, 0);
              echoLayout->addWidget(passwordLineEdit, 2, 2, 1, 2 );
              echoLayout->setRowStretch(0, 5);
              echoGroup->setLayout(echoLayout);
              
              QGridLayout *validatorLayout = new QGridLayout;
              validatorLayout->addWidget(validatorLabel, 0, 0);
              validatorLayout->addWidget(validatorComboBox, 0, 1);
              validatorLayout->addWidget(validatorLineEdit, 1, 0, 1, 2);
              validatorGroup->setLayout(validatorLayout);
              
              QGridLayout *alignmentLayout = new QGridLayout;
              alignmentLayout->addWidget(alignmentLabel, 0, 0);
              alignmentLayout->addWidget(alignmentComboBox, 0, 1);
              alignmentLayout->addWidget(alignmentLineEdit, 1, 0, 1, 2);
              alignmentGroup-> setLayout(alignmentLayout);
              
              
              QGridLayout *grid = new QGridLayout;
              grid->addWidget(createFirstGroup(), 0, 1);
              grid->heightForWidth(10);
              grid->setRowStretch(0,50);
              
              //setWindowTitle(tr("Radio Buttons"));
              
              
              QGridLayout *layout = new QGridLayout;
              layout->addWidget(echoGroup, 0, 0);
              layout->addWidget(validatorGroup, 1, 0);
              layout->addWidget(alignmentGroup, 2, 0);
              layout->addWidget(createFirstGroup(), 0, 1);
              //layout->addWidget(accessGroup, 1, 1);
              setLayout(layout);
              
              setWindowTitle(tr("Line Edits"));
              

              }

              QGroupBox *Window::createFirstGroup()
              {
                  QGroupBox *groupBox = new QGroupBox(tr("Radio Buttons group"));
              
                  QRadioButton *radio1 = new QRadioButton(tr("&Radio button 1"));
                  QRadioButton *radio2 = new QRadioButton(tr("R&adio button 2"));
                  QRadioButton *radio3 = new QRadioButton(tr("Ra&dio button 3"));
              
                  radio1->setChecked(true);
              
                  QVBoxLayout *vbox = new QVBoxLayout;
                  vbox->addWidget(radio1);
                  vbox->addWidget(radio2);
                  vbox->addWidget(radio3);
                  vbox->addStretch(1);
                  groupBox->setLayout(vbox);
                  resize(100, 200);
              
                  return groupBox;
              }
              
              void Window::echoChanged(int index)
              {
                  switch (index) {
                  case 0:
                      echoLineEdit->setEchoMode(QLineEdit::Normal);
                      break;
                  case 1:
                      echoLineEdit->setEchoMode(QLineEdit::Password);
                      break;
                  case 2:
                      echoLineEdit->setEchoMode(QLineEdit::PasswordEchoOnEdit);
                      break;
                  case 3:
                      echoLineEdit->setEchoMode(QLineEdit::NoEcho);
                      break;
                  }
              }
              
              void Window::validatorChanged(int index)
              {
                  switch (index) {
                  case 0:
                      validatorLineEdit->setValidator(nullptr);
                      break;
                  case 1:
                      validatorLineEdit->setValidator(new QIntValidator(
                          validatorLineEdit));
                      break;
                  case 2:
                      validatorLineEdit->setValidator(new QDoubleValidator(-999.0,
                          999.0, 2, validatorLineEdit));
                      break;
                  }
              
                  validatorLineEdit->clear();
              }
              
              void Window::alignmentChanged(int index)
              {
                  switch (index) {
                  case 0:
                      alignmentLineEdit->setAlignment(Qt::AlignLeft);
                      break;
                  case 1:
                      alignmentLineEdit->setAlignment(Qt::AlignCenter);
                      break;
                  case 2:
                      alignmentLineEdit->setAlignment(Qt::AlignRight);
                      break;
                  }
              }
              
              

              void Window::onCurrentTextChanged(const QString &text)
              {
              qDebug() << QString(" entered text is ")<< text;
              passwordLineEdit->setPlaceholderText("Password entered is : ");
              passwordLineEdit->setText(text);
              passwordLineEdit->show();
              passwordLineEdit->setEchoMode(QLineEdit::PasswordEchoOnEdit);
              }

              C 1 Reply Last reply
              0
              • C curiosity

                @Christian-Ehrlicher
                //NewWidget.cpp

                #include "NewWidget.h"
                #include <iostream>
                using namespace std;
                
                #include <QComboBox>
                #include <QGridLayout>
                #include <QGroupBox>
                #include <QLabel>
                #include <QLineEdit>
                #include <QtWidgets>
                
                
                Window::Window(QWidget *parent) QWidget(parent)
                {
                    QGroupBox *echoGroup = new QGroupBox(tr("Echo"));
                
                QLabel *echoLabel = new QLabel(tr("Mode:"));
                QComboBox *echoComboBox = new QComboBox;
                echoComboBox->addItem(tr("Normal"));
                echoComboBox->addItem(tr("Password"));
                echoComboBox->addItem(tr("PasswordEchoOnEdit"));
                echoComboBox->addItem(tr("No Echo"));
                
                
                echoLineEdit = new QLineEdit;
                echoLineEdit->setPlaceholderText("Placeholder Text");
                
                QLabel *passwordLabel = new QLabel(tr("Password entered is :"));
                passwordLineEdit = new QLineEdit;
                
                QGroupBox *validatorGroup = new QGroupBox(tr("Validator"));
                
                QLabel *validatorLabel = new QLabel(tr("Type:"));
                QComboBox *validatorComboBox = new QComboBox;
                validatorComboBox->addItem(tr("No validator"));
                validatorComboBox->addItem(tr("Integer validator"));
                validatorComboBox->addItem(tr("Double validator"));
                
                validatorLineEdit = new QLineEdit;
                validatorLineEdit->setPlaceholderText("Placeholder Text");
                
                QGroupBox *alignmentGroup = new QGroupBox(tr("Alignment"));
                
                QLabel *alignmentLabel = new QLabel(tr("Type:"));
                QComboBox *alignmentComboBox = new QComboBox;
                alignmentComboBox->addItem(tr("Left"));
                alignmentComboBox->addItem(tr("Centered"));
                alignmentComboBox->addItem(tr("Right"));
                
                alignmentLineEdit = new QLineEdit;
                alignmentLineEdit->setPlaceholderText("Placeholder Text");/>
                
                connect(echoComboBox,&QComboBox::editTextChanged, this, &Window::onCurrentTextChanged);
                
                connect(validatorComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated),this, &Window::validatorChanged);
                connect(alignmentComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &Window::alignmentChanged);
                
                QGridLayout *echoLayout = new QGridLayout;
                echoLayout->addWidget(echoLabel, 0, 0);
                echoLayout->addWidget(echoComboBox, 0, 1, Qt::AlignLeft);
                echoLayout->addWidget(echoLineEdit, 1, 0, 1, 2);
                echoLayout->addWidget(passwordLabel, 2, 0);
                echoLayout->addWidget(passwordLineEdit, 2, 2, 1, 2 );
                echoLayout->setRowStretch(0, 5);
                echoGroup->setLayout(echoLayout);
                
                QGridLayout *validatorLayout = new QGridLayout;
                validatorLayout->addWidget(validatorLabel, 0, 0);
                validatorLayout->addWidget(validatorComboBox, 0, 1);
                validatorLayout->addWidget(validatorLineEdit, 1, 0, 1, 2);
                validatorGroup->setLayout(validatorLayout);
                
                QGridLayout *alignmentLayout = new QGridLayout;
                alignmentLayout->addWidget(alignmentLabel, 0, 0);
                alignmentLayout->addWidget(alignmentComboBox, 0, 1);
                alignmentLayout->addWidget(alignmentLineEdit, 1, 0, 1, 2);
                alignmentGroup-> setLayout(alignmentLayout);
                
                
                QGridLayout *grid = new QGridLayout;
                grid->addWidget(createFirstGroup(), 0, 1);
                grid->heightForWidth(10);
                grid->setRowStretch(0,50);
                
                //setWindowTitle(tr("Radio Buttons"));
                
                
                QGridLayout *layout = new QGridLayout;
                layout->addWidget(echoGroup, 0, 0);
                layout->addWidget(validatorGroup, 1, 0);
                layout->addWidget(alignmentGroup, 2, 0);
                layout->addWidget(createFirstGroup(), 0, 1);
                //layout->addWidget(accessGroup, 1, 1);
                setLayout(layout);
                
                setWindowTitle(tr("Line Edits"));
                

                }

                QGroupBox *Window::createFirstGroup()
                {
                    QGroupBox *groupBox = new QGroupBox(tr("Radio Buttons group"));
                
                    QRadioButton *radio1 = new QRadioButton(tr("&Radio button 1"));
                    QRadioButton *radio2 = new QRadioButton(tr("R&adio button 2"));
                    QRadioButton *radio3 = new QRadioButton(tr("Ra&dio button 3"));
                
                    radio1->setChecked(true);
                
                    QVBoxLayout *vbox = new QVBoxLayout;
                    vbox->addWidget(radio1);
                    vbox->addWidget(radio2);
                    vbox->addWidget(radio3);
                    vbox->addStretch(1);
                    groupBox->setLayout(vbox);
                    resize(100, 200);
                
                    return groupBox;
                }
                
                void Window::echoChanged(int index)
                {
                    switch (index) {
                    case 0:
                        echoLineEdit->setEchoMode(QLineEdit::Normal);
                        break;
                    case 1:
                        echoLineEdit->setEchoMode(QLineEdit::Password);
                        break;
                    case 2:
                        echoLineEdit->setEchoMode(QLineEdit::PasswordEchoOnEdit);
                        break;
                    case 3:
                        echoLineEdit->setEchoMode(QLineEdit::NoEcho);
                        break;
                    }
                }
                
                void Window::validatorChanged(int index)
                {
                    switch (index) {
                    case 0:
                        validatorLineEdit->setValidator(nullptr);
                        break;
                    case 1:
                        validatorLineEdit->setValidator(new QIntValidator(
                            validatorLineEdit));
                        break;
                    case 2:
                        validatorLineEdit->setValidator(new QDoubleValidator(-999.0,
                            999.0, 2, validatorLineEdit));
                        break;
                    }
                
                    validatorLineEdit->clear();
                }
                
                void Window::alignmentChanged(int index)
                {
                    switch (index) {
                    case 0:
                        alignmentLineEdit->setAlignment(Qt::AlignLeft);
                        break;
                    case 1:
                        alignmentLineEdit->setAlignment(Qt::AlignCenter);
                        break;
                    case 2:
                        alignmentLineEdit->setAlignment(Qt::AlignRight);
                        break;
                    }
                }
                
                

                void Window::onCurrentTextChanged(const QString &text)
                {
                qDebug() << QString(" entered text is ")<< text;
                passwordLineEdit->setPlaceholderText("Password entered is : ");
                passwordLineEdit->setText(text);
                passwordLineEdit->show();
                passwordLineEdit->setEchoMode(QLineEdit::PasswordEchoOnEdit);
                }

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

                @Christian-Ehrlicher

                I tried formatting it. but this was how it shoed up after posting NewWidget.cpp

                #ifndef WINDOW_H
                #define WINDOW_H
                
                #include <QWidget>
                #include <QLineEdit>
                #include <QDebug>
                
                QT_BEGIN_NAMESPACE
                class QLineEdit;
                class QGroupBox;
                QT_END_NAMESPACE
                
                
                class Window : public QWidget
                {
                    Q_OBJECT
                
                public:
                    QLineEdit *passwordLineEdit;
                
                    Window(QWidget *parent = nullptr);
                
                private:
                    QLineEdit *echoLineEdit;
                    QLineEdit *validatorLineEdit;
                    QLineEdit *alignmentLineEdit;
                
                public slots:
                    void echoChanged(int);
                    void validatorChanged(int);
                    void alignmentChanged(int);
                    QGroupBox *createFirstGroup();
                
                };
                
                #endif
                

                //Main.cpp

                #include <QApplication>
                
                #include "NewWidget.h"
                
                int main(int argc, char *argv[])
                {
                    QApplication app(argc, argv);
                    Window window;
                    window.show();
                    return app.exec();
                }
                

                code is compiling and running.. except that it is not echoing the text entered

                Christian EhrlicherC JonBJ C 4 Replies Last reply
                0
                • C curiosity

                  @Christian-Ehrlicher

                  I tried formatting it. but this was how it shoed up after posting NewWidget.cpp

                  #ifndef WINDOW_H
                  #define WINDOW_H
                  
                  #include <QWidget>
                  #include <QLineEdit>
                  #include <QDebug>
                  
                  QT_BEGIN_NAMESPACE
                  class QLineEdit;
                  class QGroupBox;
                  QT_END_NAMESPACE
                  
                  
                  class Window : public QWidget
                  {
                      Q_OBJECT
                  
                  public:
                      QLineEdit *passwordLineEdit;
                  
                      Window(QWidget *parent = nullptr);
                  
                  private:
                      QLineEdit *echoLineEdit;
                      QLineEdit *validatorLineEdit;
                      QLineEdit *alignmentLineEdit;
                  
                  public slots:
                      void echoChanged(int);
                      void validatorChanged(int);
                      void alignmentChanged(int);
                      QGroupBox *createFirstGroup();
                  
                  };
                  
                  #endif
                  

                  //Main.cpp

                  #include <QApplication>
                  
                  #include "NewWidget.h"
                  
                  int main(int argc, char *argv[])
                  {
                      QApplication app(argc, argv);
                      Window window;
                      window.show();
                      return app.exec();
                  }
                  

                  code is compiling and running.. except that it is not echoing the text entered

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

                  Please read my post carefully and fix the errors in your code.

                  1 Reply Last reply
                  0
                  • C curiosity

                    @Christian-Ehrlicher

                    I tried formatting it. but this was how it shoed up after posting NewWidget.cpp

                    #ifndef WINDOW_H
                    #define WINDOW_H
                    
                    #include <QWidget>
                    #include <QLineEdit>
                    #include <QDebug>
                    
                    QT_BEGIN_NAMESPACE
                    class QLineEdit;
                    class QGroupBox;
                    QT_END_NAMESPACE
                    
                    
                    class Window : public QWidget
                    {
                        Q_OBJECT
                    
                    public:
                        QLineEdit *passwordLineEdit;
                    
                        Window(QWidget *parent = nullptr);
                    
                    private:
                        QLineEdit *echoLineEdit;
                        QLineEdit *validatorLineEdit;
                        QLineEdit *alignmentLineEdit;
                    
                    public slots:
                        void echoChanged(int);
                        void validatorChanged(int);
                        void alignmentChanged(int);
                        QGroupBox *createFirstGroup();
                    
                    };
                    
                    #endif
                    

                    //Main.cpp

                    #include <QApplication>
                    
                    #include "NewWidget.h"
                    
                    int main(int argc, char *argv[])
                    {
                        QApplication app(argc, argv);
                        Window window;
                        window.show();
                        return app.exec();
                    }
                    

                    code is compiling and running.. except that it is not echoing the text entered

                    Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #44
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • C curiosity

                      @Christian-Ehrlicher

                      I tried formatting it. but this was how it shoed up after posting NewWidget.cpp

                      #ifndef WINDOW_H
                      #define WINDOW_H
                      
                      #include <QWidget>
                      #include <QLineEdit>
                      #include <QDebug>
                      
                      QT_BEGIN_NAMESPACE
                      class QLineEdit;
                      class QGroupBox;
                      QT_END_NAMESPACE
                      
                      
                      class Window : public QWidget
                      {
                          Q_OBJECT
                      
                      public:
                          QLineEdit *passwordLineEdit;
                      
                          Window(QWidget *parent = nullptr);
                      
                      private:
                          QLineEdit *echoLineEdit;
                          QLineEdit *validatorLineEdit;
                          QLineEdit *alignmentLineEdit;
                      
                      public slots:
                          void echoChanged(int);
                          void validatorChanged(int);
                          void alignmentChanged(int);
                          QGroupBox *createFirstGroup();
                      
                      };
                      
                      #endif
                      

                      //Main.cpp

                      #include <QApplication>
                      
                      #include "NewWidget.h"
                      
                      int main(int argc, char *argv[])
                      {
                          QApplication app(argc, argv);
                          Window window;
                          window.show();
                          return app.exec();
                      }
                      

                      code is compiling and running.. except that it is not echoing the text entered

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

                      @curiosity
                      There is an awful lot of code (and discussion) here, I am lost as to where you are at. In the following order:

                      1. connect(echoComboBox,&QComboBox::editTextChanged, this, [](const QString &text) { qDebug() << "text:" << text; } );
                        Does this work?

                      2. connect(echoComboBox,&QComboBox::editTextChanged, this, &Window::onCurrentTextChanged);
                        Where Window::onCurrentTextChanged(const QString &text) slot has qDebug() << "text:" << text; as its first statement.
                        Does this work?

                      3. Once those are working. If text does not show from passwordLineEdit->setText(text); where you have gone passwordLineEdit->setEchoMode(QLineEdit::PasswordEchoOnEdit); try without PasswordEchoOnEdit, I don't know if that interferes with what you can do or see when you mark a line edit as being for password entry.

                      Christian EhrlicherC 1 Reply Last reply
                      0
                      • JonBJ JonB

                        @curiosity
                        There is an awful lot of code (and discussion) here, I am lost as to where you are at. In the following order:

                        1. connect(echoComboBox,&QComboBox::editTextChanged, this, [](const QString &text) { qDebug() << "text:" << text; } );
                          Does this work?

                        2. connect(echoComboBox,&QComboBox::editTextChanged, this, &Window::onCurrentTextChanged);
                          Where Window::onCurrentTextChanged(const QString &text) slot has qDebug() << "text:" << text; as its first statement.
                          Does this work?

                        3. Once those are working. If text does not show from passwordLineEdit->setText(text); where you have gone passwordLineEdit->setEchoMode(QLineEdit::PasswordEchoOnEdit); try without PasswordEchoOnEdit, I don't know if that interferes with what you can do or see when you mark a line edit as being for password entry.

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

                        @JonB It can not work. See my comment about local and member variable. C++ basic stuff.

                        JonBJ 1 Reply Last reply
                        0
                        • Christian EhrlicherC Christian Ehrlicher

                          @JonB It can not work. See my comment about local and member variable. C++ basic stuff.

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

                          @Christian-Ehrlicher
                          Hi Christian. Per your comment I did try searching this page for echoLabel (got a bit confused in the formatting), I thought I saw it was a local newed variable. But that's not to do with connecting?

                          Did you mean echoCombobox? But that is also newed and in scope when connect()ed, and I did not come across a member variable of that name instead? Maybe I mis-searched....

                          Maybe I should leave you to it, you have perhaps copied the code and played with it.

                          Christian EhrlicherC 1 Reply Last reply
                          0
                          • JonBJ JonB

                            @Christian-Ehrlicher
                            Hi Christian. Per your comment I did try searching this page for echoLabel (got a bit confused in the formatting), I thought I saw it was a local newed variable. But that's not to do with connecting?

                            Did you mean echoCombobox? But that is also newed and in scope when connect()ed, and I did not come across a member variable of that name instead? Maybe I mis-searched....

                            Maybe I should leave you to it, you have perhaps copied the code and played with it.

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

                            @JonB You might be right. The code formatting (and useless reposting instead editing the former post) and the difference between the source and the header which makes the whole stuff uncompilable as the header is missing the slot definition for onCurrentTextChanged() confused me. Wonder (every time again) what's so hard writing a minimal and compileable example.

                            JonBJ 1 Reply Last reply
                            0
                            • Christian EhrlicherC Christian Ehrlicher

                              @JonB You might be right. The code formatting (and useless reposting instead editing the former post) and the difference between the source and the header which makes the whole stuff uncompilable as the header is missing the slot definition for onCurrentTextChanged() confused me. Wonder (every time again) what's so hard writing a minimal and compileable example.

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

                              @Christian-Ehrlicher
                              If you are correct OP will not even get past my point #1. That is why I suggest they follow those in order and we will know where they do/do not get to :)

                              1 Reply Last reply
                              0
                              • C curiosity

                                @Christian-Ehrlicher

                                I tried formatting it. but this was how it shoed up after posting NewWidget.cpp

                                #ifndef WINDOW_H
                                #define WINDOW_H
                                
                                #include <QWidget>
                                #include <QLineEdit>
                                #include <QDebug>
                                
                                QT_BEGIN_NAMESPACE
                                class QLineEdit;
                                class QGroupBox;
                                QT_END_NAMESPACE
                                
                                
                                class Window : public QWidget
                                {
                                    Q_OBJECT
                                
                                public:
                                    QLineEdit *passwordLineEdit;
                                
                                    Window(QWidget *parent = nullptr);
                                
                                private:
                                    QLineEdit *echoLineEdit;
                                    QLineEdit *validatorLineEdit;
                                    QLineEdit *alignmentLineEdit;
                                
                                public slots:
                                    void echoChanged(int);
                                    void validatorChanged(int);
                                    void alignmentChanged(int);
                                    QGroupBox *createFirstGroup();
                                
                                };
                                
                                #endif
                                

                                //Main.cpp

                                #include <QApplication>
                                
                                #include "NewWidget.h"
                                
                                int main(int argc, char *argv[])
                                {
                                    QApplication app(argc, argv);
                                    Window window;
                                    window.show();
                                    return app.exec();
                                }
                                

                                code is compiling and running.. except that it is not echoing the text entered

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

                                @Christian-Ehrlicher @JonB
                                sorry for the typos.. please read as the " this was how it showed*** up after posting NewWidget.cpp

                                JonBJ 1 Reply Last reply
                                0
                                • C curiosity

                                  @Christian-Ehrlicher @JonB
                                  sorry for the typos.. please read as the " this was how it showed*** up after posting NewWidget.cpp

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

                                  @curiosity I don't know where you are at now, but if you answer where you get to in the 3 steps I suggested earlier we may know where whatever issue lies.

                                  C 1 Reply Last reply
                                  0
                                  • JonBJ JonB

                                    @curiosity I don't know where you are at now, but if you answer where you get to in the 3 steps I suggested earlier we may know where whatever issue lies.

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

                                    @JonB

                                    your point 1 isnt working.. i have a break point inside my connect statement and i tried debugging.

                                    i have following error

                                    "mincore\com\oleaut32\dispatch\ups.cpp(2122)\OLEAUT32.dll!00007FFCE48BA726: (caller: 00007FFCE48B9B39) ReturnHr(1) tid(3250) 8002801D Library not registered."

                                       QObject::connect(echoComboBox, &QComboBox::currentTextChanged, this,  [&](const QString &text) {
                                           qDebug() << "text:" << text;/* i have a breakpoint here which is not getting hit also text is not printed to console*/
                                             Window::onCurrentTextChanged(text);
                                    
                                           echoLineEdit->show();
                                       });
                                    
                                    C 1 Reply Last reply
                                    0
                                    • C curiosity

                                      @JonB

                                      your point 1 isnt working.. i have a break point inside my connect statement and i tried debugging.

                                      i have following error

                                      "mincore\com\oleaut32\dispatch\ups.cpp(2122)\OLEAUT32.dll!00007FFCE48BA726: (caller: 00007FFCE48B9B39) ReturnHr(1) tid(3250) 8002801D Library not registered."

                                         QObject::connect(echoComboBox, &QComboBox::currentTextChanged, this,  [&](const QString &text) {
                                             qDebug() << "text:" << text;/* i have a breakpoint here which is not getting hit also text is not printed to console*/
                                               Window::onCurrentTextChanged(text);
                                      
                                             echoLineEdit->show();
                                         });
                                      
                                      C Offline
                                      C Offline
                                      curiosity
                                      wrote on last edited by
                                      #53

                                      @JonB
                                      Its working now.. the signal was emitted from QCombobox.but it should have been

                                         QObject::connect(echoLineEdit, &QLineEdit::textChanged, this,  [&](const QString &text) {
                                             Window::onCurrentTextChanged(text);
                                             echoLineEdit->show();
                                         });
                                      

                                      Now it is working as expected

                                      Pl45m4P 1 Reply Last reply
                                      1
                                      • C curiosity

                                        @JonB
                                        Its working now.. the signal was emitted from QCombobox.but it should have been

                                           QObject::connect(echoLineEdit, &QLineEdit::textChanged, this,  [&](const QString &text) {
                                               Window::onCurrentTextChanged(text);
                                               echoLineEdit->show();
                                           });
                                        

                                        Now it is working as expected

                                        Pl45m4P Offline
                                        Pl45m4P Offline
                                        Pl45m4
                                        wrote on last edited by Pl45m4
                                        #54

                                        @curiosity said in QPointerEvent throws error:

                                        Now it is working as expected

                                        Great, then mark the topic as solved.

                                        Beside the discussion about syntax and other stuff and I believe it was mentioned here before....
                                        your lambda is not needed and the content does not make too much sense.

                                        Window::onCurrentTextChanged(text);

                                        In what scope this is called? If you are in Window and you pass this to your labda, you don't need the fully qualified function name.

                                        echoLineEdit->show();

                                        Calling show() after the text has changed is not needed unless you never insert text manully but always set text programmatically with setText(...).
                                        But even then, connecting to slot onCurrentTextChanged(text) in Window would be way easier.


                                        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                                        ~E. W. Dijkstra

                                        C 1 Reply Last reply
                                        1
                                        • Pl45m4P Pl45m4

                                          @curiosity said in QPointerEvent throws error:

                                          Now it is working as expected

                                          Great, then mark the topic as solved.

                                          Beside the discussion about syntax and other stuff and I believe it was mentioned here before....
                                          your lambda is not needed and the content does not make too much sense.

                                          Window::onCurrentTextChanged(text);

                                          In what scope this is called? If you are in Window and you pass this to your labda, you don't need the fully qualified function name.

                                          echoLineEdit->show();

                                          Calling show() after the text has changed is not needed unless you never insert text manully but always set text programmatically with setText(...).
                                          But even then, connecting to slot onCurrentTextChanged(text) in Window would be way easier.

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

                                          @Pl45m4

                                          if you say that lambda is not needed, in which context do we use lambda for connect statements

                                          jsulmJ 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