50 frozenTableView = new QTableView(this); |
50 frozenTableView = new QTableView(this); |
51 |
51 |
52 init(); |
52 init(); |
53 |
53 |
54 //connect the headers and scrollbars of both tableviews together |
54 //connect the headers and scrollbars of both tableviews together |
55 connect(horizontalHeader(),SIGNAL(sectionResized ( int ,int,int )), this, |
55 connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)), this, |
56 SLOT(updateSectionWidth(int, int, int))); |
56 SLOT(updateSectionWidth(int,int,int))); |
57 connect(verticalHeader(),SIGNAL(sectionResized ( int ,int,int )), this, |
57 connect(verticalHeader(),SIGNAL(sectionResized(int,int,int)), this, |
58 SLOT(updateSectionHeight(int, int, int))); |
58 SLOT(updateSectionHeight(int,int,int))); |
59 |
59 |
60 connect(frozenTableView->verticalScrollBar(), SIGNAL(valueChanged(int)), |
60 connect(frozenTableView->verticalScrollBar(), SIGNAL(valueChanged(int)), |
61 verticalScrollBar(), SLOT(setValue(int))); |
61 verticalScrollBar(), SLOT(setValue(int))); |
62 connect(verticalScrollBar(), SIGNAL(valueChanged(int)), |
62 connect(verticalScrollBar(), SIGNAL(valueChanged(int)), |
63 frozenTableView->verticalScrollBar(), SLOT(setValue(int))); |
63 frozenTableView->verticalScrollBar(), SLOT(setValue(int))); |
82 viewport()->stackUnder(frozenTableView); |
82 viewport()->stackUnder(frozenTableView); |
83 //! [init part1] |
83 //! [init part1] |
84 |
84 |
85 //! [init part2] |
85 //! [init part2] |
86 frozenTableView->setStyleSheet("QTableView { border: none;" |
86 frozenTableView->setStyleSheet("QTableView { border: none;" |
87 "background-color: #8EDE21;}"); //for demo purposes |
87 "background-color: #8EDE21;" |
|
88 "selection-background-color: #999}"); //for demo purposes |
88 frozenTableView->setSelectionModel(selectionModel()); |
89 frozenTableView->setSelectionModel(selectionModel()); |
89 for(int col=1; col<model()->columnCount(); col++) |
90 for(int col=1; col<model()->columnCount(); col++) |
90 frozenTableView->setColumnHidden(col, true); |
91 frozenTableView->setColumnHidden(col, true); |
91 |
92 |
92 frozenTableView->setColumnWidth(0, columnWidth(0) ); |
93 frozenTableView->setColumnWidth(0, columnWidth(0) ); |