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 resize vertical header in QTableWidget
Qt 6.11 is out! See what's new in the release blog

How to resize vertical header in QTableWidget

Scheduled Pinned Locked Moved General and Desktop
13 Posts 4 Posters 8.7k Views 3 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.
  • A Offline
    A Offline
    alex_malyu
    wrote on last edited by
    #4

    try ui->InsurancePremiumTable->verticalHeader()- setSizeHint( QSize (500,500 ) );

    1 Reply Last reply
    0
    • T Offline
      T Offline
      technovelist
      wrote on last edited by
      #5

      No, that doesn't compile.
      1>mainwindow.cpp(737): error C3861: 'setSizeHint': identifier not found

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alex_malyu
        wrote on last edited by alex_malyu
        #6
        This post is deleted!
        1 Reply Last reply
        0
        • K Offline
          K Offline
          killerman
          wrote on last edited by killerman
          #7

          Try this:

          ui->InsurancePremiumTable->verticalHeader->setResizeMode(QHeaderView::Fixed);
          ui->InsurancePremiumTable->verticalHeader->setDefaultSectionSize( 500 );
          

          Or:

          ui->InsurancePremiumTable->verticalHeader->setResizeMode(QHeaderView::Fixed);
          ui->InsurancePremiumTable->verticalHeader()->resize( 500, 500 );
          

          If it doesn't help try changing size for a single row:

          ui->InsurancePremiumTable->setRowHeight( rowNumber, rowHeight );
          
          1 Reply Last reply
          0
          • T Offline
            T Offline
            technovelist
            wrote on last edited by technovelist
            #8

            This doesn't compile:
            ui->InsurancePremiumTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);

            I get this error:
            mainwindow.cpp(736): error C2039: 'setResizeMode' : is not a member of 'QHeaderView'

            and if I write it as you did,
            ui->InsurancePremiumTable->verticalHeader->setResizeMode(QHeaderView::Fixed);

            then I get a different error:
            1>mainwindow.cpp(736): error C2227: left of '->setResizeMode' must point to class/struct/union/generic type

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

              Hi,

              You are missing a #include <QHeaderView> in mainwindow.cpp file

              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
              • T Offline
                T Offline
                technovelist
                wrote on last edited by
                #10

                Nope, that doesn't help; I get the same error:
                1>mainwindow.cpp(745): error C2039: 'setResizeMode' : is not a member of 'QHeaderView'

                Any other suggestions?

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

                  Because it's an obsolete function, see here for the replacement

                  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
                  • T Offline
                    T Offline
                    technovelist
                    wrote on last edited by
                    #12

                    That compiles okay but doesn't do anything visible other than wiping out my label

                    Here's my code:

                    ui->InsurancePremiumTable->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
                    ui->InsurancePremiumTable->verticalHeader()->resizeSection(0, 500);
                    m_InsurancePremiumRowNames.append("Ins.    Premium");
                    ui->InsurancePremiumTable->setVerticalHeaderLabels(m_InsurancePremiumRowNames);
                    for (int row = 0; row < ui->InsurancePremiumTable->rowCount(); ++row)
                    	for (int column = 0; column < ui->InsurancePremiumTable->columnCount(); ++column)
                    	{
                    		QTableWidgetItem *newItem = new QTableWidgetItem("");
                    		ui->InsurancePremiumTable->setItem(row, column, newItem);
                    	}
                    
                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #13

                      Your header width gets pretty big, isn't 500pixel a bit wide ?

                      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

                      • Login

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