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. QTableWidget set font for individual cells?
Forum Updated to NodeBB v4.3 + New Features

QTableWidget set font for individual cells?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 793 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.
  • P Offline
    P Offline
    Publicnamer
    wrote on last edited by
    #1

    Is it possible to set different fonts for different QTableWidget cells?
    I noticed that I can set a font for the headers but I really need different fonts within the table.

    eyllanescE 1 Reply Last reply
    0
    • P Publicnamer

      Is it possible to set different fonts for different QTableWidget cells?
      I noticed that I can set a font for the headers but I really need different fonts within the table.

      eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by
      #2

      @Publicnamer Use https://doc.qt.io/qt-5/qtablewidgetitem.html#setFont, please read the docs:

      QFont font("Times", 10, QFont::Bold)
      
      auto item = tableWidget->item(row, column);
      item->setFont(font);
      

      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
      5
      • Christian EhrlicherC Online
        Christian EhrlicherC Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        The font for a cell can be changed by returning the desired font for Qt::FontRole which you can set in your item via QTableWidgetItem::setFont().

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        4

        • Login

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