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. [SOLVED] QTableView Alignment
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QTableView Alignment

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 2.9k 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.
  • guidupasG Offline
    guidupasG Offline
    guidupas
    wrote on last edited by
    #1

    Hello everyone!

    I am trying to align a QTableView column and its is not working.

    When I do this it works fine:
    @
    modeloLancamentosInvestimento->setData(modeloLancamentosInvestimento->index(modeloLancamentosInvestimento->rowCount()-1, 0), Qt::AlignRight, Qt::TextAlignmentRole);
    @

    But I need to align it vertically at the center to and when i try it does not work:
    @
    modeloLancamentosInvestimento->setData(modeloLancamentosInvestimento->index(modeloLancamentosInvestimento->rowCount()-1, 0), Qt::AlignRight | Qt::AlignVCenter, Qt::TextAlignmentRole);
    @

    How can I do that?

    Thanks all.

    Att.
    Guilherme Cortada Dupas

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

      Hi,

      What kind of model do you have under ?

      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
      • guidupasG Offline
        guidupasG Offline
        guidupas
        wrote on last edited by
        #3

        Sorry about that.

        I have a QTableView

        Att.
        Guilherme Cortada Dupas

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

          I know that you are using a QTableView, the question is what is the model that you use ?

          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
          • guidupasG Offline
            guidupasG Offline
            guidupas
            wrote on last edited by
            #5

            Its a QStandardItemModel

            Att.
            Guilherme Cortada Dupas

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

              Then you should use QStandardItem::setAlignement

              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
              • guidupasG Offline
                guidupasG Offline
                guidupas
                wrote on last edited by
                #7

                SGaist, thank you very much. It worked

                @
                QStandardItem *itemTabela = modeloLancamentosInvestimento->item(modeloLancamentosInvestimento->rowCount()-1, 0);
                itemTabela->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
                @

                Att.
                Guilherme Cortada Dupas

                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