Reputation: 1796
Well this proves I'm a noob at coding! I've looked everywhere and still can't get this right. This should be pretty simple.
I have been trying this:
int i;
for(i=0;i<16;i++)
{
QChar q = QChar(memblock[i]);
QString s = QString(q);
QTableWidgetItem *item = new QTableWidgetItem(s);
ui->tableWidget->setItem(rowCount, colCount, item);
}
So I'm making table items from each string. That's because I also couldn't figure out how to make table items from just a QChar, or plain char.
But each cell ends up with:
Ý
Whereas when I add in:
cout << memblock[i];
It properly shows:
RIFFd2 WAVEfmt
Here is the code that reads in the raw data:
ifstream file (text, ios::in|ios::binary|ios::ate);
if (file.is_open())
{
size = file.tellg();
memblock = new char [size];
file.seekg(0, ios::beg);
file.read(memblock, size);
file.close();
}
Also, when I do cout << &memblock[i]
, for i from 0 to 4 I get:
RIFFd2
IFFd2
FFd2
Fd2
And so on.
Upvotes: 0
Views: 1230
Reputation: 608
I've managed to use some simplified variant of your code with Qt 4.8.3 and MSVC 2010:
ui.tableWidget->setColumnCount(5);
ui.tableWidget->setRowCount(5);
char *memChunck = new char[25];
for ( int i = 0; i < 25; ++i ) {
memChunck[i] = i + 65;
}
for ( int i = 0; i < 25; ++i ) {
QTableWidgetItem *item = new QTableWidgetItem(QString::number( memChunck[i], 16).toUpper() );
ui.tableWidget->setItem(i / 5, i % 5, item);
}
Upvotes: 3