Placing the text in proper poistions on QTableWidgetItem



  • I am trying to add some text on QTableWidgetItem by appropriately adding some spaces, to have a better visibility.

    on the terminal the spacing looks perfect , but not the table.
    the string len is falling in the range only...

    please let me know how to do it correctly...
    @
    char eveinfo[80];
    QString eventInfo;

    memset(eveinfo,' ',80*sizeof(char));
    strncpy(eveinfo, (const char *)event_list[row].event_name,strlen((const char )event_list[row].event_name));
    strncpy(&eveinfo[40],starttime,strlen(starttime));
    strncpy(&eveinfo[47],"to",strlen("to"));
    strncpy(&eveinfo[51],endtime,strlen(endtime));
    strncpy(&eveinfo[70], actdate,strlen(actdate));
    eveinfo[79]='\0';
    eventInfo = eveinfo
    // eventInfo = QString::fromUtf16((ushort
    )(eveinfo)); This is giving garbages
    table->setItem(row,1,new QTableWidgetItem(eventInfo));

    @


  • Lifetime Qt Champion

    Hi,

    Why don't you just use QString ?

    @QString eventInfo = QString("%1 to %2 %3).arg(starttime).arg(endtime).arg(actdate);@



  • Can you please write it correctly i am getting same string as out put instead of its value..


  • Lifetime Qt Champion

    Can you show what you except to have ?



  • my problem is that i want to set text on a QTableWidgetItem with proper allignment , thats the reason i am using all that memset and strncpy setup, but when displaying the text is not aligned.

    i want to know just assigning from char [] to QString works correct or gives any problem, as i am facing problem with spaces.

    please let me know how to convert char [] to Qstring properly


  • Lifetime Qt Champion

    I understood your problem. What I would like to have is a concrete example of that alignment you are talking about so I may help you implement it.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.