Search code examples
c++qtsignalssignals-slots

Sending text from QTextEdit to QListWidget on pushing QPushButton - Qt


So, I have the following design:

List box
Text box
Push button

When I push the button, the text from the text box should go to the list box.

QTextEdit has the following signal:
void QTextEdit::textChanged () [signal]

But, doesn't this mean that when user presses an alphabet, a signal will be sent? But, I want the whole paragraph to go to the list box (at once) on the push of the button.

Should I send the data from text box to button and then from button to list box? Or there another way out?

EDIT 1:

I have been successful in sending the text from list box to the button, but how to send the text from button to list box?

Button has no signal which sends the text.


Solution

  • you should handle QPushButtons's clicked signal and then in that signal you can get QTextEdit's text content by toPlainText () API and you can insert this to List box's model