March 26, 2012

umen242 umen242
Lab Rat
344 posts

Qt QSqlQueryModel::setQuery control what display in in the column

 

Im using :

  1. QString query = "SELECT foo,n1,n2 FROM play_list";
  2. QSqlQueryModel::setQuery(query, queryDB);

in QSqlQueryModel subclass , but i dont want to display all the results that i getting from the select , i want to use the data and display only foo in the display and others results in others things . how can it be done?

4 replies

March 26, 2012

dridk dridk
Lab Rat
48 posts

Hide column in the view, not in the model.
For exemple :

  1. QTableView::setColumnHidden ( int column, bool hide )

 Signature 

Nothing in Biology Makes Sense Except in the Light of Evolution

April 1, 2012

umen242 umen242
Lab Rat
344 posts

but i like to use the data from the other columns

April 5, 2012

Volker Volker
Ant Farmer
5428 posts

Subclassing QSortFilterProxyModel and reimplementing method filterAcceptsColumn() should do the trick.

April 9, 2012

Andre Andre
Robot Herder
6295 posts

Hiding the data from the view does not stop you from using the data in other contexts…

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

 
  ‹‹ [Solved] QLineEdit input incorrectly uppercased      QGraphicsItem child’s type() ››

You must log in to post a reply. Not a member yet? Register here!