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 to set font size to horizontal header of QTableView
Forum Updated to NodeBB v4.3 + New Features

How to set font size to horizontal header of QTableView

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

    Hi,

    I tried to find solution for this on google but I couldn't.

    I tried set font size in both code and stylesheet but they don't work:

    @ui->tblView->horizontalHeader()->setFont(QFont("Tahoma", 20));@

    @QTableView#tblView QHeaderView::section:horizontal
    {
    font-size: 20px;
    font-family: "Tahoma";
    }@

    Please help, thanks.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      You could try to use the relevant data role in QAbstractItemModel::headerData for that.

      1 Reply Last reply
      0
      • H Offline
        H Offline
        highlandcoffee
        wrote on last edited by
        #3

        Hi Andre,

        I will try and report back to you. Thank you.

        1 Reply Last reply
        0
        • H Offline
          H Offline
          highlandcoffee
          wrote on last edited by
          #4

          Hi Andre,

          I tried to find some relevant data role in QAbstractItemModel::headerData and thought that FontRole can help me. But nothing's change even I used FontRole

          @QVariant UploadedTableModel::headerData(int section, Qt::Orientation orientation, int role) const
          {
          if (role == Qt::FontRole)
          return QFont("Tahoma", 14);
          ...
          @

          Maybe I miss something else. Can you please advice?

          1 Reply Last reply
          1

          • Login

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