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. allign text in TableView
Forum Updated to NodeBB v4.3 + New Features

allign text in TableView

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 297 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.
  • saulosS Offline
    saulosS Offline
    saulos
    wrote on last edited by
    #1

    Hi, I have Tableview connected to a SqlTableModel and all the column are left aligned, numeric don't show the 2 digits if they are 00.
    First i will like to understand if this is due to the MySql connector or the field definition on the DB,
    Second how can I correct this ?
    Thanks a lot

    JonBJ 1 Reply Last reply
    0
    • saulosS saulos

      Hi, I have Tableview connected to a SqlTableModel and all the column are left aligned, numeric don't show the 2 digits if they are 00.
      First i will like to understand if this is due to the MySql connector or the field definition on the DB,
      Second how can I correct this ?
      Thanks a lot

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #2

      @saulos
      This has nothing to do with field definitions in the database or the connector.

      See https://doc.qt.io/qt-5/qabstractitemmodel.html#data and https://doc.qt.io/qt-5/qt.html#ItemDataRole-enum for the Qt::TextAlignmentRole role. For number output format control, you are intended to create a https://doc.qt.io/qt-5/qstyleditemdelegate.html for your view.

      1 Reply Last reply
      3
      • eyllanescE Offline
        eyllanescE Offline
        eyllanesc
        wrote on last edited by eyllanesc
        #3

        @saulos You must use a delegate (QStyledItemDelegate) to correct how that information is displayed, for example override displayText().

        If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

        1 Reply Last reply
        2
        • saulosS Offline
          saulosS Offline
          saulos
          wrote on last edited by
          #4

          Thanks, I will look at your suggestions.
          :)

          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