I have a QListWidget with its selectionMode set to QAbstractView.ExtendedSelection. So I can select multiple items (rows) in the QListWidget.

If I select multiple items, press Copy (Ctrl+C), and then paste the result elsewhere, either in a Qt text widget or in some non-Qt place, I get the text of only the last item. How can I get the selection to include the text of all the selected items, separated by newlines or something like that?