Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Placing the text in proper poistions on QTableWidgetItem
Forum Updated to NodeBB v4.3 + New Features

Placing the text in proper poistions on QTableWidgetItem

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dcqt
    wrote on last edited by
    #1

    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));

    @

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Why don't you just use QString ?

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Dcqt
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Can you show what you except to have ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • D Offline
            D Offline
            Dcqt
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              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.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved