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. Adding tableview to scene, appearing small and with scroll bars
Forum Updated to NodeBB v4.3 + New Features

Adding tableview to scene, appearing small and with scroll bars

Scheduled Pinned Locked Moved Solved General and Desktop
qgraphicsviewqtableviewqt desktop
18 Posts 2 Posters 2.1k 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by mrjj
    #4

    Hi
    Normally you assign some portion of the form to the table and if its bigger, it get scrollbars.

    Is your goal to sum up all the header size so that it never will show scrollbars ?

    Anyway, you could do like

    .....
      indexPageTableView->resizeColumnsToContents();
    
       int width = (indexPageModel->columnCount() - 1) + indexPageTableView->verticalHeader()->width();    
            for (int column = 0; column < indexPageModel->columnCount(); column++)    
                width = width + indexPageTableView->columnWidth(column);    
      indexPageTableView->setMinimumWidth(width);
    

    alt text

    1 Reply Last reply
    1
    • S Offline
      S Offline
      sachinrd
      wrote on last edited by
      #5

      This works perfect . Thanks you so much.

      mrjjM 1 Reply Last reply
      0
      • S sachinrd

        This works perfect . Thanks you so much.

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #6

        @sachinrd
        Np. providing code I can just run always help the motivation to have a look.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sachinrd
          wrote on last edited by
          #7

          Hi @mrjj . I am finding it difficult in one more problem w.r.t to the current thread. with the solution that you have given above i am able to set geometry for the tableview so that scroll bars dont appear. this works in mac. but in windows the height and width doesnt fit the actual height and width and scroll bars are appearing.(so is the solution platform independent?) Can you pls help me here ?
          Thanks for the help in advance.

          mrjjM 1 Reply Last reply
          0
          • S sachinrd

            Hi @mrjj . I am finding it difficult in one more problem w.r.t to the current thread. with the solution that you have given above i am able to set geometry for the tableview so that scroll bars dont appear. this works in mac. but in windows the height and width doesnt fit the actual height and width and scroll bars are appearing.(so is the solution platform independent?) Can you pls help me here ?
            Thanks for the help in advance.

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #8

            @sachinrd
            Hi that is a bit odd as I did this on windows to test :)
            It should be platform independent but as with all font stuff, there might be
            difference.

            So how many pixels are missing for it not to show scrollbars ?

            like
            indexPageTableView->setMinimumWidth(width+25);

            or much , much more ?

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sachinrd
              wrote on last edited by
              #9
              This post is deleted!
              1 Reply Last reply
              0
              • S Offline
                S Offline
                sachinrd
                wrote on last edited by
                #10

                Hi @mrjj . Thanks for the quick reply. around some 20 to 25 pixels is missing . we are doing resizeColumnsToContents() right. This should be considering the font sizes right ?

                mrjjM 1 Reply Last reply
                0
                • S sachinrd

                  Hi @mrjj . Thanks for the quick reply. around some 20 to 25 pixels is missing . we are doing resizeColumnsToContents() right. This should be considering the font sizes right ?

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11

                  @sachinrd
                  Hi
                  yes resizeColumnsToContents();
                  should calculate the needed space with the current font.
                  and we then add up the needed sizes and expand the view.

                  Do you use any stylesheet or anything that could make the calculation a bit off ?

                  I don't see it here from a fast test so i wonder what difference it.

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    sachinrd
                    wrote on last edited by
                    #12

                    @mrjj . yeah i am using this style:
                    indexPageTableView->setStyleSheet("QTableView::item{border: 2px solid black}");

                    mrjjM 1 Reply Last reply
                    0
                    • S sachinrd

                      @mrjj . yeah i am using this style:
                      indexPageTableView->setStyleSheet("QTableView::item{border: 2px solid black}");

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #13

                      @sachinrd
                      Hi
                      Ok
                      can you check without if its then accurate ?

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        sachinrd
                        wrote on last edited by
                        #14

                        sure let me check.

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          sachinrd
                          wrote on last edited by
                          #15
                          This post is deleted!
                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            sachinrd
                            wrote on last edited by sachinrd
                            #16

                            Hi @mrjj . i have removed the stylesheet changes. it still didnt work!
                            61207492-5a56-4b7a-898c-82485b8a54ea-image.png

                            mrjjM 1 Reply Last reply
                            0
                            • S sachinrd

                              Hi @mrjj . i have removed the stylesheet changes. it still didnt work!
                              61207492-5a56-4b7a-898c-82485b8a54ea-image.png

                              mrjjM Offline
                              mrjjM Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on last edited by
                              #17

                              @sachinrd
                              Hi
                              try setting
                              alt text

                              and see if then the table is not fully drawn.
                              I recall it will "reserve" some space for the scrollbars and hence the width of a scrollbar is missing in the calcualation.

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                sachinrd
                                wrote on last edited by
                                #18

                                @mrjj . Thanks a ton for your help. Its working perfectly.

                                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