Where are the Signals?
-
Am I missing something or does the QTextEdit widget not have a signal for key pressed , especially return to let you know that the user has accepted the input?
I might also be missing the obvious, but QPushButton seems to have no signals at all, according to the class reference. I would expect a mouse click at least.
If the class reference in Help is wrong, is there any sort of definitive list signals?
-
@lonnie hi,
IIRC QTextEdit has no Signal for that, you'll have to derive that class if you want such signals. However you should look intoQTextEdit
, that one has build in Signals you want.void editingFinished() void returnPressed()
QPushButton has no own new Signals, however it inherits from QAbstractButton, therefore it has Signals
void clicked(bool checked = false) void pressed() void released() void toggled(bool checked)
-
Hi Ionnie,
there is a virtual protected keyPressed Event in
QTextEdit
inherited fromQWidget
. So you can subclassQTextEdit
and overwrite it.For
QPushButton
the signal is inheited fromQAbstractButton
as you can see here:
http://doc.qt.io/qt-5/qabstractbutton.html#clickedFor a definite list you can click on "List of all members, including inherited members" in Help of a Class.
-
Skip this post. Sorry.
QPushButton does in fact have a clicked signal. The help is a bit deficient and that is frustrating because it, at first, seemed to be so well done and thorough. Now I am seeing it is "mostly" well done and rough around the edges. I got quite used to the trial and error method in C#, so I guess I am back to that.
QTextEdit emits signals for textChanged but only when the widget is initially loaded. Nothing happens when I type a bunch of stuff and hit enter. Kind of makes it difficult if you wanted to validate the contents before moving to another field.
Note to others:
I found this out by messing with the line:
connect(edit, SIGNAL(textChanged()), this, SLOT(on_lineEditReturn()));Just edit it to become: connect(edit, SIGNAL)), this, SLOT(on_lineEditReturn()));
and as soon as you type the opening bracket after SIGNAL it pops up a list of the available signals. Very helpful. -
@sneubert said in Where are the Signals?:
For a definite list you can click on "List of all members, including inherited members" in Help of a Class.
Very helpful thanks. I guess I was distracted by the fact that some of the Class References list all the Slots and Signals.
-
@J.Hilk said in Where are the Signals?:
However you should look into QTextEdit, that one has build in Signals you want.
Thanks. I assume you meant QLineEdit which does seem to have a BUNCH of things. I guess it is time to step away from the keyboard and do some in depth class info skimming. Also, I need to forget C#. haha
-
@sneubert I will have to look at subclassing because I want the multiline capability of QTextEdit. Only problem, and I see why it was left out, is that Enter is not the end of edit in a Multiline. It merely inserts another line. I'll take at look at the Focus events.
Thanks for your suggestion.
-
@lonnie said in Where are the Signals?:
Nothing happens when I type a bunch of stuff and hit enter.
that's when
editingFinished()
gets emitted@lonnie said in Where are the Signals?:
Kind of makes it difficult if you wanted to validate the contents before moving to another field.
That's what QValidator and its subclasses are for. You can use
QTextEdit::setValidator
to apply it to your edit