Unsolved tableView and disappearing items
-
Hello.
I'm using tableView to display database data and I can fix this annoying bug.I've created a button to refresh data:
void Przychodnia::on_buttonOdswiez_clicked() { QSqlTableModel *model = new QSqlTableModel(); model->setTable("Pacjent"); model->setEditStrategy(QSqlTableModel::OnManualSubmit); model->select(); ui->tableView->setModel(model); }
This is my tableView before fetching data:
http://imgur.com/h6zq8dWThis is my tableView after fetching data:
http://imgur.com/XxU3qS7This is my tableview after hovering on items:
http://imgur.com/Xn7pK1HHowever if I edit data in listView (that also is not showing my items) the results are displayed in table view and they are not disappearing:
http://imgur.com/dYnqwdtI'm working with SAP 16 database on Virtual Machine win7- 64bit with Qt Creator 3.6 based on Qt 5.5.1.
Best regards!
-
Hi and welcome to devnet,
Are you saying the you have your indexes disappearing while hovering them ?
On a side note you have a "memory leak" here, each time your call
on_buttonOdswiez_clicked
, you replace the current model with another new one and don't delete the original. -
@SGaist
Yes. They are disappearing when i hover oveer them and then I need to press the button.
I don't know what can cause this because my friend is using basicly the same code .Thank you for memory leak info.
-
Are you both using the same OS and Qt version ?
-
@SGaist
Yes.
I think the VirtualBox cause the problem since I'm working on it and he is not. -
Did you install the VirtualBox guest tools ?
-
@SGaist
Guest Addition tools?
Yes since I had problems with resolution.
Tried running Qt without them and with different settings. Nothing worked. -
What version of VirtualBox is it ?
-
@SGaist
5.0.12 -
What is the host OS ?
-
@SGaist
Windows 8 64-bit . -
Ok so I have done some research and it seems like the problem occur only if there are more then 1 rows in column.
The indexes are working fine when there is only one row in table. -
What do you mean by "more then 1 rows in column" ?
-
@SGaist
Its fine to have one row in tableview but when i add more than one the bug appears.Single row:
http://imgur.com/sDniGmWMultirow:
http://imgur.com/uIxyxdD -
Do you have any QSqlRelationalDelegate on it ?
-
@SGaist
Not really. I'm new to Qt and I'm still learning how things works. -
Your two images show two different tables. Are you sure that both tables contains data ?