Combo box showing multiple concatenated columns of table?



  • Hi,
    I don't know if this is possible, however in my code I've got:

    @void LoginDialog::setUsernamesModel( QSqlTableModel* model){
    comboUsername->setModel( model );
    comboUsername->setModelColumn( model->fieldIndex( "username" ) );
    }@

    that sets a qsqltablemodel into a combobox so to show the column username. Now I'd like the combo to display also the name and surname columns concatenated with the username one, so that the resulting text is name + surname + (username), such as for instance "Luca Ferrari (luca.ferrari)". Is that possible without having to define my own model and/or to create a view of the database table with a fake column that contains the text concatenation I want and attach the model to such view?



  • No, I don't think so. I think your best bet is using a QSqlTableModel subclass or a proxy model.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.