I am not interested in bypassing my error using lambda
Using a lambda expression does not bypass anything. It is simply an alternative to defining an actual slot or other method with the correct function signature. In your original post with two list widgets, you couldn't use the new style version of connect() that uses the QOverload<> syntax because your version of Qt is probably too old, and you couldn't use the old style version because it requires addItem() to be a slot and it isn't.
Now in your new code you are trying to connect a signal that sends an apple to a slot that wants an orange. Your error seems to be in thinking that somehow you can connect something to anything else and arguments will magically get converted. As I said already, signals and slots are just C++ functions, and you can't call a C++ function with the wrong number or types of arguments.
The XML works by coping a string from list and appending it to plain text.
How is that possible? There is no itemClicked() signal from QListWidget that sends a text string, so it is not possible in QtDesigner or anywhere else to connect a QListWidget itemClicked() signal to -any- slot that expects a text string as an argument. The ui XML code will compile, because the UIC and MOC compilers will create the old style connect() statement in its code, but it will not work at run time because the function signatures do not match.
The only QListWidget signal that returns a string is currentTextChanged(). So the only possible working signal / slot connection you could have made in QtDesigner would be to connect QListWidget::currentTextChanged() to QPlainTextEdit::appendPlainText(), and that will result in whatever text was clicked on in the list widget getting copied and appended to the text edit. Neither the signal nor the slot are overloaded methods, so you could use either the old or new style of connect() to make the connection.
connect( ui
->list,
SIGNAL( currentTextChanged
( const QString & ) ), ui
->plainTextEdit,
SLOT( appendPlainText
( const QString & ) ) );
// or
connect( ui->list, &QListWidget::currentTextChanged, ui->plainTextEdit, &QPlainTextEdit::appendPlainText );
connect( ui->list, SIGNAL( currentTextChanged( const QString & ) ), ui->plainTextEdit, SLOT( appendPlainText( const QString & ) ) );
// or
connect( ui->list, &QListWidget::currentTextChanged, ui->plainTextEdit, &QPlainTextEdit::appendPlainText );
To copy to clipboard, switch view to plain text mode
In any case, there is no execution of XML code. The XML file edited by QtDesigner is simply instructions to the UIC and MOC compilers that tell them how to generate the C++ code that defines the user interfaces and instantiate it at run time, including making any signal and slot connections that have been defined in the ui file. That C++ code will always compile because connect() statements that get generated are the old style, which use method names as strings and not as addresses of member functions (as the new style does). New style connect() statements will fail to compile if the functions do not match. Old style connect() will compile, but at run time will fail because Qt's meta-object system will not be able to match up the function at that time.
Bookmarks