Results 1 to 2 of 2

Thread: Storing String in QTableWidgetItem with proper alignmenet

  1. #1
    Join Date
    Mar 2013
    Location
    Hyderabad,Bangalore,India
    Posts
    70
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Storing String in QTableWidgetItem with proper alignmenet

    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.

    Qt Code:
    1. char cstr[80];
    2. memset(cstr,' ',80*sizeof(char)); // Fill with 80 spaces
    3.  
    4. strncpy(cstr, desc[row],strlen(edesc[row])); // copy few chars into cstr , length does not exceed 40
    5. strncpy(&cstr[40],(const char *)stime,strlen(stime));
    6. strncpy(&cstr[47],"to",strlen("to"));
    7. strncpy(&cstr[51],(const char *)etime,strlen(etime));
    8. strncpy(&cstr[70], (const char *)date,strlen(date));
    9. cstr[79]='\0';
    10.  
    11. QString qstr = cstr;
    12.  
    13. item(row,1)->setText(qstr);
    To copy to clipboard, switch view to plain text mode 

    Thanks,

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Storing String in QTableWidgetItem with proper alignmenet

    Your code does not touch anything alignment related.

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

    Cheers,
    _

Similar Threads

  1. String length limited in QTableWidgetItem
    By joseprl89 in forum Qt Programming
    Replies: 4
    Last Post: 25th September 2013, 12:34
  2. Storing A hex value as a string?
    By Splatify in forum Newbie
    Replies: 4
    Last Post: 7th February 2011, 06:26
  3. Flag storing
    By bismitapadhy in forum Qt Programming
    Replies: 1
    Last Post: 24th June 2009, 05:26
  4. std:string how to change into system:string?
    By yunpeng880 in forum Qt Programming
    Replies: 1
    Last Post: 14th April 2009, 08:51
  5. storing captions
    By vijay anandh in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 07:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.