Integrate Combobox with Tableview QT

Asked

Viewed 31 times

1

I have a table Courses:

create table Cursos(
ID_curso int not null auto_increment,
Nome_curso varchar (50),
primary key (ID_curso)
)default charset = utf8;

And another registered table:

create table Cadastrados(
Nome varchar(50),
Matricula varchar(9) unique,
Curso_id int not null,
primary key (Matricula),
foreign key (Curso_id) references Cursos (ID_Curso)
)default charset = utf8;

Creating the interface with Qt, I managed to list all courses within a combobox:

ui->setupUi(this);
QSqlQueryModel *model = new QSqlQueryModel;
model->setQuery("select nome_curso from Cursos");
ui->comboBox->setModel(model);

But now I want to select some course of the combobox, and make appear a list with all the registrants of that respective course (I thought to use the tableView for this). But I have no idea where to start. Could someone give me a light?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.