Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Combo box showing multiple concatenated columns of table?
QtWS25 Last Chance

Combo box showing multiple concatenated columns of table?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fluca1978
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved