PDA

View Full Version : Storing String in QTableWidgetItem with proper alignmenet



PstdEr
18th April 2014, 10:14
Hi,

I need to set text on QTableWidgetItem with proper alignment between text , i following below , but the text does not allign properly
request to let me know what is the proper way of doing it.



char cstr[80];
memset(cstr,' ',80*sizeof(char)); // Fill with 80 spaces

strncpy(cstr, desc[row],strlen(edesc[row])); // copy few chars into cstr , length does not exceed 40
strncpy(&cstr[40],(const char *)stime,strlen(stime));
strncpy(&cstr[47],"to",strlen("to"));
strncpy(&cstr[51],(const char *)etime,strlen(etime));
strncpy(&cstr[70], (const char *)date,strlen(date));
cstr[79]='\0';

QString qstr = cstr;

item(row,1)->setText(qstr);


Thanks,

anda_skoa
18th April 2014, 11:05
Your code does not touch anything alignment related.

And you might want to think about your string handling there.

Cheers,
_