#include <QtGui>
int main(int argc, char *argv[])
{
qt->verticalHeader()->setVisible(false);
qt->setRowCount(85);
qt->setColumnCount(4);
qt->setSortingEnabled(false);
qt->setHorizontalHeaderItem(0, __colItem);
qt->setHorizontalHeaderItem(1, __colItem2);
qt->setHorizontalHeaderItem(2, __colItem3);
qt->setHorizontalHeaderItem(2, __colItem4);
for(int i = 0; i < 75; i++){
if(i < 10){
} else {
}
//if(isSortingEnabled()) ==== false!!!!
qt->setItem(i, 0, ax[i]);
qt->setItem(qt->row(ax[i]), 1, ax2[i]);
qt->setItem(qt->row(ax[i]), 2, ax3[i]);
qt->setItem(qt->row(ax[i]), 3, ax4[i]);
}
qt->setSortingEnabled(true);
//qt->sortItems(0, Qt::AscendingOrder);
qt->sortByColumn(0, Qt::AscendingOrder);
qt->show();
return app.exec();
}
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTableWidget* qt = new QTableWidget;
qt->verticalHeader()->setVisible(false);
qt->setRowCount(85);
qt->setColumnCount(4);
qt->setSortingEnabled(false);
QTableWidgetItem *__colItem = new QTableWidgetItem();
__colItem->setText(QApplication::translate("t", "t1", 0, QApplication::UnicodeUTF8));
qt->setHorizontalHeaderItem(0, __colItem);
QTableWidgetItem *__colItem2 = new QTableWidgetItem();
__colItem2->setText(QApplication::translate("t", "t2", 0, QApplication::UnicodeUTF8));
qt->setHorizontalHeaderItem(1, __colItem2);
QTableWidgetItem *__colItem3 = new QTableWidgetItem();
__colItem3->setText(QApplication::translate("t", "t3", 0, QApplication::UnicodeUTF8));
qt->setHorizontalHeaderItem(2, __colItem3);
QTableWidgetItem *__colItem4 = new QTableWidgetItem();
__colItem4->setText(QApplication::translate("t", "t4", 0, QApplication::UnicodeUTF8));
qt->setHorizontalHeaderItem(2, __colItem4);
QTableWidgetItem* ax[75];
QTableWidgetItem* ax2[75];
QTableWidgetItem* ax3[75];
QTableWidgetItem* ax4[75];
QString num;
for(int i = 0; i < 75; i++){
if(i < 10){
num = QString("0%1").arg(i);
} else {
num = QString("%1").arg(i);
}
//if(isSortingEnabled()) ==== false!!!!
ax[i] = new QTableWidgetItem(QString("QA%1").arg(num));
ax2[i] = new QTableWidgetItem(QString("QB%1").arg(num));
ax3[i] = new QTableWidgetItem(QString("QC%1").arg(num));
ax4[i] = new QTableWidgetItem(QString("QD%1").arg(num));
qt->setItem(i, 0, ax[i]);
qt->setCellWidget(qt->row(ax[i]), 0, new QPushButton(QString("QA%1").arg(num)));
qt->setItem(qt->row(ax[i]), 1, ax2[i]);
qt->setCellWidget(qt->row(ax[i]), 1, new QPushButton(QString("QB%1").arg(num)));
qt->setItem(qt->row(ax[i]), 2, ax3[i]);
qt->setItem(qt->row(ax[i]), 3, ax4[i]);
}
qt->setSortingEnabled(true);
//qt->sortItems(0, Qt::AscendingOrder);
qt->sortByColumn(0, Qt::AscendingOrder);
qt->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks