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

How to resize vertical header in QTableWidget

Scheduled Pinned Locked Moved General and Desktop
13 Posts 4 Posters 8.0k 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 2 May 2015, 00:11 last edited by
    #4

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

    1 Reply Last reply
    0
    • T Offline
      T Offline
      technovelist
      wrote on 2 May 2015, 00:34 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 2 May 2015, 01:33 last edited by alex_malyu 5 Feb 2015, 01:55
        #6
        This post is deleted!
        1 Reply Last reply
        0
        • K Offline
          K Offline
          killerman
          wrote on 2 May 2015, 07:17 last edited by killerman 5 Feb 2015, 07:22
          #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 2 May 2015, 15:25 last edited by technovelist 5 Feb 2015, 15:28
            #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
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 2 May 2015, 19:24 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 3 May 2015, 00:00 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
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 3 May 2015, 00:31 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 3 May 2015, 15:19 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
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 3 May 2015, 21:41 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

                      13/13

                      3 May 2015, 21:41

                      • Login

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