Using 4.2, and have some issues w/ a QTableWidget.
First, and foremost, I'm trying to make cells completely unselectable and unfocus-able. I thought this would work for, but will not. Even w/ this below, all cells are both focus & select-friendly.
tbl->setFocusPolicy( Qt::NoFocus );
QTableWidget *tbl = new QTableWidget( 0, 8, this );
tbl->setSelectionMode( QAbstractItemView::NoSelection );
tbl->setFocusPolicy( Qt::NoFocus );
To copy to clipboard, switch view to plain text mode
Also, I have a pretty simple piece of code (I thought). Read in a line, make a new row (at row 0 -- at the top of the widget), change the height of that row. I posted this on the QT Interest ML, and didn't get much help. AFAIK, there's no weird indexing. setRowHeight(x) should change the height of row x, no matter when it was added to the QTableWidget.
void mywidget::read_line()
{
char* cfg_file = getenv("FILE");
while ( !file.atEnd() ) {
if ( vals.size() == no_of_cols ) { // valid line of text
tbl_trades->insertRow( 0 ); // new row
tbl_trades->setRowHeight( 0, 20 ); // resize new row
for ( int i = 0; i < no_of_cols; i++ ) { //
tbl_trades->setItem( 0, i, temp );
}
}
}
}
}
void mywidget::read_line()
{
char* cfg_file = getenv("FILE");
QFile file( cfg_file );
if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
while ( !file.atEnd() ) {
QByteArray line = file.readLine();
QStringList vals = QStringList::split( ',', line, 0 );
if ( vals.size() == no_of_cols ) { // valid line of text
tbl_trades->insertRow( 0 ); // new row
tbl_trades->setRowHeight( 0, 20 ); // resize new row
for ( int i = 0; i < no_of_cols; i++ ) { //
QTableWidgetItem *temp = new QTableWidgetItem( vals[i] );
tbl_trades->setItem( 0, i, temp );
}
}
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks