March 26, 2012

umen242 umen242
Lab Rat
198 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
56 posts

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

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


Nothing in Biology Makes Sense Except in the Light of Evolution

April 1, 2012

umen242 umen242
Lab Rat
198 posts

but i like to use the data from the other columns

April 5, 2012

Volker Volker
Ant Farmer
5331 posts

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

April 9, 2012

Andre Andre
Robot Herder
6663 posts

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

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

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