关于QTableWidget的两个问题
先上代码:
#include <QtGui>class Widget : public QWidget{ Q_OBJECTprivate: QTableWidget *tableWidget; QPushButton *showButton;public: Widget(QWidget *parent = 0); public slots: void ClickedShowButton();};Widget::Widget(QWidget *parent /* = 0 */): QWidget(parent){ resize(400, 300); tableWidget = new QTableWidget(3, 3, this); showButton = new QPushButton("show", this); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(tableWidget); layout->addWidget(showButton); setLayout(layout); connect(showButton, SIGNAL(clicked()), this, SLOT(ClickedShowButton())); tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); for(int i=0; i<3; i++) { for(int j=0; j<3; j++) { QString str = QString::number(i) + QString::number(j); tableWidget->setItem(i, j, new QTableWidgetItem(str)); } }}void Widget::ClickedShowButton(){ QMessageBox::information(this, "AA", "Show");}#include "main.moc"int main(int argc, char **argv){ QApplication app(argc, argv); Widget *widget = new Widget; widget->show(); return app.exec();}QTableWidget QHeaderView::section{ font:...;}