hello there, i have created a table using QTableWidget class which is inserted inside a tabWidget. i want to add a character "*" diagonally across all the cells which relate to the same number i.e. stick "*" which relates to (0,0)(1,1) and (2,2) etc because i dont want the user to enter any data in they fields. i tried using addItem( ) with a while loop and a for loop to add in the character but this gave me errors after running the program. is there any quick way to do this without having to use addItem individually for each cell?? heres my code that i tried to use for the table:
DemandsTab:emandsTab(const QFileInfo &fileInfo, QWidget *parent)
: QWidget(parent)
{
int rows = 0, columns = 0;
QLabel *testme = new QLabel(tr("Suck it the 4th time"));
QTableWidget *demands = new QTableWidget(this);
demands->setRowCount(10);
demands->setColumnCount(10);
int row = demands->rowCount();
int column = demands->columnCount();
QTableWidgetItem *nodesHeaderItem = new QTableWidgetItem(tr("Cubes"));
nodesHeaderItem->setTextAlignment(Qt::AlignVCenter);
QTableWidgetItem *asterix = new QTableWidgetItem(tr("*").arg((row+1)+(column+1)));
---------------heres where the problem lies-------
for(int i=0;i<10;i++)
{
demands->setItem(rows, columns, asterix);
rows++;
columns++;
)
-----------------------------------------------------------
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(testme);
mainLayout->addWidget(demands);
mainLayout->addStretch(0);
setLayout(mainLayout);
}
any help would be much appreciated thanks, Jag
Bookmarks