Results 1 to 5 of 5

Thread: QTableWidget::verticalScrollBar()->maximum() is always 0

  1. #1
    Join Date
    Jul 2016
    Posts
    7
    Qt products
    Qt5
    Platforms
    MacOS X

    Default QTableWidget::verticalScrollBar()->maximum() is always 0

    In my application there are 3 tables. I update them in callback from QProcess with listing from the external program – after calling rowCount(0), i.e. after first clearing the tables. First two tables have vertical QScrollBar::maximum() automatically updated so that I know what is the QScrollBar's maximum setValue() argument. However, not knowing why, third table has maximum() stuck at 0. What can be the cause? The code is the same for the 3 tables, and in general, maximum() should be updated as I call insertRow(), this should be an independent action. Why it isn't updated in the single table?

    Currently I solve this by calling setMaximum() before setValue() – I set the maximum to a large number, two times larger than number of rows in QTableWidget.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QTableWidget::verticalScrollBar()->maximum() is always 0

    Why it isn't updated in the single table?
    I'm guessing you have a bug in your code. But since you haven't shown us any code, that's all it is, a guess. I could guess something else, but I think "a bug" is a good guess, so I'll stick with it.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jul 2016
    Posts
    7
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: QTableWidget::verticalScrollBar()->maximum() is always 0

    It's hard to provide small piece of code but I can first provide the whole project. Few helper conclusions:
    1. Scroll bar positions are remembered in rememberScrollBars();
    2. First two QTableWidgets (ui->tableWidget, ui->tableWidget_2) are being filled with insertLZCSDTableRow()
    3. The third (problematic) QTableWidget is being filled with insertLZSDETableRow() (so LZSDE, not LZCSD)
    4. The QProcess-triggered callbacks that provide data for the tables are: handle_zkiresize_list() for tableWidget&tableWidget_2, handle_zkiresize_consistent() for tableWidget_3
    5. Vertical scroll bar position is restored (comment "RESTORE SCROLL", 3 times in code) via e.g. ui->tableWidget_3->verticalScrollBar()->setValue(...)
    6. I now always call setMaximum() to a large value (two times the expected maximum) before calling setValue(), and this helps


    Who knows, maybe someone would like to build this project. CMake can build everything, but there are also .pro files, and one could just fix libraries paths in it. I guess building own libgit2 might not be a great idea, but it's fixable by just changing library reference to an external one, in manager.pro file. To run the project one needs psprint/zkl github repository placed at ~/.zekyll/repos/gh---psprint---zkl---master, and backend "zekyll" (https://github.com/psprint/zekyll) placed at ~/.zekyll/zekyll

    The source:

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget::verticalScrollBar()->maximum() is always 0

    Overriding the maximum of a table view's scrollbar doesn't sound like a very good idea.
    That value is usually determined by the table's data, i.e. how many rows it has an how high these rows are.

    Cheers,
    _

  5. #5
    Join Date
    Jul 2016
    Posts
    7
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: QTableWidget::verticalScrollBar()->maximum() is always 0

    Quote Originally Posted by anda_skoa View Post
    Overriding the maximum of a table view's scrollbar doesn't sound like a very good idea.
    That value is usually determined by the table's data, i.e. how many rows it has an how high these rows are.

    Cheers,
    _
    Yeah, but in my case, 1 out of 3 QTableWidgets doesn't have maximum() of verticalScrollBar updated. That's the point, the value is stuck at 0 despite insertRow() calls

Similar Threads

  1. Maximum value of ProgressBar
    By jesse_mark in forum Newbie
    Replies: 4
    Last Post: 10th January 2013, 15:27
  2. How to use verticalScrollBar? [SOLVED]
    By micamica in forum Newbie
    Replies: 4
    Last Post: 19th July 2011, 07:33
  3. Maximum PNG dimensions?
    By blooglet in forum Qt Programming
    Replies: 6
    Last Post: 5th May 2011, 09:49
  4. [Qt3] Two QListviews - VerticalScrollBar Sync Problems
    By BrainB0ne in forum Qt Programming
    Replies: 0
    Last Post: 25th September 2008, 12:18
  5. verticalScrollBar on the left
    By Lele in forum Qt Programming
    Replies: 3
    Last Post: 10th August 2006, 16:32

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.