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 top-left corner properties
Forum Updated to NodeBB v4.3 + New Features

QTableWidget top-left corner properties

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 10.4k 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.
  • X Offline
    X Offline
    xtingray
    wrote on last edited by
    #1

    Hi,

    I'm just curious if it's possible to access and set properties to the top-left cell of a QTableWidget when the horizontal and vertical headers are visible.

    If there is a chance, I would like to set a little text in that cell. All I could find about it was the "cornerWidget()":http://qt-project.org/doc/qt-5/qabstractscrollarea.html#cornerWidget method of the QTableView class but I am not sure if I am following the right clue.

    Any help is very welcome! :)


    Qt Developer

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      -It's not a cell. It's actually outside of the table and yes, that's the corner widget.-
      Sorry. That's not right. That's actually a fragment between scroll bars.

      This cell is actually a button that selects all cells. There's no method exposed to get to it but if you call on the table children<QPushButton> or children<QToolButton> or something like this you might be able to get a pointer to it and change its text.

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

        Hi,

        I don't want to ruin the thing, but if you are thinking about the "select all cells" corner button, then it's an internal widget called QTableCornerButton that you can't modify from the outside at least officially

        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
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          What he said :P

          1 Reply Last reply
          0
          • X Offline
            X Offline
            xtingray
            wrote on last edited by
            #5

            Well, my requirement is to set a text right there for usability/information reasons only. No interaction is needed, no buttons, no actions.

            But as far as you said, it seems impossible for now :/


            Qt Developer

            1 Reply Last reply
            0
            • Chris KawaC Offline
              Chris KawaC Offline
              Chris Kawa
              Lifetime Qt Champion
              wrote on last edited by Chris Kawa
              #6

              Don't give up so easily ;)

              There's an easy way to do it with a few more lines of code:

              label = new QLabel("Txt!", tableWidget);
              label->setAlignment(Qt::AlignCenter);
              label->setAttribute(Qt::WA_TransparentForMouseEvents);
              
              connect(tableWidget->verticalHeader(), &QHeaderView::geometriesChanged, whatever, &Whatever::resizeCorner);
              connect(ui->tableWidget->horizontalHeader(), &QHeaderView::geometriesChanged, whatever, &Whatever::resizeCorner);
              
              //slot in Whatever class
              void Whatever::resizeCorner() {
                 label->setGeometry(0, 0, tableWidget->verticalHeader()->width(),
                                          tableWidget->horizontalHeader()->height());
              }
              

              This doesn't use any hacks or internal Qt stuff so it's a pretty clean solution.

              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