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. how do i perform center text in Qtablewidget

how do i perform center text in Qtablewidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 8.7k Views
  • 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.
  • F Offline
    F Offline
    farhanrbn
    wrote on last edited by
    #1

    hi guys i wanna ask for help here,

    how do i perform center tex in Qtablewidget?

    just to make it clear, here is the preview of my table:

    0_1554787650085_d0166276-c2e3-45a4-98f0-a21778285fa2-image.png

    i want the text below the header is center, what should i do?
    every answer it'll be appriciate it.

    thank you

    jsulmJ 1 Reply Last reply
    0
    • F farhanrbn

      hi guys i wanna ask for help here,

      how do i perform center tex in Qtablewidget?

      just to make it clear, here is the preview of my table:

      0_1554787650085_d0166276-c2e3-45a4-98f0-a21778285fa2-image.png

      i want the text below the header is center, what should i do?
      every answer it'll be appriciate it.

      thank you

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @farhanrbn See documentation: https://doc.qt.io/qt-5/qtablewidgetitem.html#setTextAlignment

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        Its a setting on the item.
        QTableWidgetItem* item = new QTableWidgetItem( "text is here" );
        item->setTextAlignment( Qt::AlignCenter );
        ui->tableWidget->setItem(1,0,item);

        1 Reply Last reply
        2
        • R Offline
          R Offline
          Redho B N
          wrote on last edited by
          #4

          but how do i make every item in my table align to center while all of my item is depends on my database?

          jsulmJ 1 Reply Last reply
          0
          • R Redho B N

            but how do i make every item in my table align to center while all of my item is depends on my database?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Redho-B-N In that case you should not use QTableWidget. You should use QTableView instead, with a data model,

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            R 1 Reply Last reply
            1
            • jsulmJ jsulm

              @Redho-B-N In that case you should not use QTableWidget. You should use QTableView instead, with a data model,

              R Offline
              R Offline
              Redho B N
              wrote on last edited by
              #6

              @jsulm and hows to use that exactly, im sorry still news to this

              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