Here is a snippit of the code I am trying to write, which creates a view of a table, displays it, and then prints it. The display works great, the data prints great, but I haven't been able to get the column headers to print yet.
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
QSqlQueryModel *BRmodel = new QSqlQueryModel;
BRmodel->setQuery(dbrStr);
if (BRmodel->rowCount() > 0 ){
QTableView *view = new QTableView;
view->setModel(BRmodel);
view->show();
// add code to create html page from BRmodel row and column data
QPrinter *printer = new QPrinter;
QPainter p(printer);
QFont Courier10("Courier",10);
p.setFont(Courier10);
int x_pos = 20;
int y_pos = 20;
QHeaderView *viewhhdr = view->horizontalHeader();
QString hdrtxt;
for (int col = 0; col < viewhhdr->count(); ++col){
hdrtxt += viewhhdr->model()->headerData(col,Qt::Orientation::Horizontal,Qt::DisplayRole);
....
}
|
The problem is that it produces an error:
|
Source code
|
1
2
3
4
|
error C2039: 'Horizontal' : is not a member of 'Qt::Orientation'
...
...
error C2065: 'Horizontal' : undeclared identifier
|
but, the API gives:
|
Source code
|
1
|
QAbstractItemModel::headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole )
|
I have tried just "Qt::Horizontal" and it doesn't work either. I have also tried to recast several times and ways.
What's the magic formula?