QPointerEvent throws error
-
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
#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
This post is deleted! -
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
#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
@curiosity
There is an awful lot of code (and discussion) here, I am lost as to where you are at. In the following order:-
connect(echoComboBox,&QComboBox::editTextChanged, this, [](const QString &text) { qDebug() << "text:" << text; } );
Does this work? -
connect(echoComboBox,&QComboBox::editTextChanged, this, &Window::onCurrentTextChanged);
WhereWindow::onCurrentTextChanged(const QString &text)
slot hasqDebug() << "text:" << text;
as its first statement.
Does this work? -
Once those are working. If text does not show from
passwordLineEdit->setText(text);
where you have gonepasswordLineEdit->setEchoMode(QLineEdit::PasswordEchoOnEdit);
try withoutPasswordEchoOnEdit
, 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.
-
-
@curiosity
There is an awful lot of code (and discussion) here, I am lost as to where you are at. In the following order:-
connect(echoComboBox,&QComboBox::editTextChanged, this, [](const QString &text) { qDebug() << "text:" << text; } );
Does this work? -
connect(echoComboBox,&QComboBox::editTextChanged, this, &Window::onCurrentTextChanged);
WhereWindow::onCurrentTextChanged(const QString &text)
slot hasqDebug() << "text:" << text;
as its first statement.
Does this work? -
Once those are working. If text does not show from
passwordLineEdit->setText(text);
where you have gonepasswordLineEdit->setEchoMode(QLineEdit::PasswordEchoOnEdit);
try withoutPasswordEchoOnEdit
, 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.
@JonB It can not work. See my comment about local and member variable. C++ basic stuff.
-
-
@JonB It can not work. See my comment about local and member variable. C++ basic stuff.
@Christian-Ehrlicher
Hi Christian. Per your comment I did try searching this page forechoLabel
(got a bit confused in the formatting), I thought I saw it was a localnew
ed variable. But that's not to do with connecting?Did you mean
echoCombobox
? But that is alsonew
ed and in scope whenconnect()
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-Ehrlicher
Hi Christian. Per your comment I did try searching this page forechoLabel
(got a bit confused in the formatting), I thought I saw it was a localnew
ed variable. But that's not to do with connecting?Did you mean
echoCombobox
? But that is alsonew
ed and in scope whenconnect()
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.
@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.
-
@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.
@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 :) -
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
#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-Ehrlicher @JonB
sorry for the typos.. please read as the " this was how it showed*** up after posting NewWidget.cpp@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.
-
@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.
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(); });
-
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(); });
@JonB
Its working now.. the signal was emitted from QCombobox.but it should have beenQObject::connect(echoLineEdit, &QLineEdit::textChanged, this, [&](const QString &text) { Window::onCurrentTextChanged(text); echoLineEdit->show(); });
Now it is working as expected
-
@JonB
Its working now.. the signal was emitted from QCombobox.but it should have beenQObject::connect(echoLineEdit, &QLineEdit::textChanged, this, [&](const QString &text) { Window::onCurrentTextChanged(text); echoLineEdit->show(); });
Now it is working as expected
@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 passthis
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 withsetText(...)
.
But even then, connecting to slotonCurrentTextChanged(text)
inWindow
would be way easier. -
@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 passthis
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 withsetText(...)
.
But even then, connecting to slotonCurrentTextChanged(text)
inWindow
would be way easier. -
if you say that lambda is not needed, in which context do we use lambda for connect statements
@curiosity said in QPointerEvent throws error:
in which context do we use lambda for connect statements
For example if you want to pass additional parameters to the slot which do not exist in the signal.
-