Results 1 to 1 of 1

Thread: QListView resize

  1. #1
    Join Date
    Mar 2013
    Posts
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QListView resize

    Hi all!
    I have an issue, which currently works for me, but I'd like to understand the details.
    My application use custom popup menu made of QListView inside QWidget. The problem is it's height.
    I'd like to count required height and resize to it or resize widget to smaller according to position/height (when smaller, QScrollBar appears).
    The code is in PyQt, but it doesn't matter IMHO.

    When initialize an application, I set custom font. This is strange - it works with size 10, but it works incorrectly with size 9
    app.setFont(QtGui.QFont("Helvetica", 10))

    According documentation, lineSpacing is height of label plus spacing to next label
    self.__line_size = QtGui.QFontMetrics(QtGui.qApp.font()).lineSpacing( )

    This should be the inner QListView size, but when use font size 9, the result is (?sometimes?) smaller than it should be
    items_size_needed = self.__line_size * (self.view.model().rowCount()) + QtGui.QFontMetrics(QtGui.qApp.font()).overlinePos( )

    At the end, I resize it this way:
    self.view.resize(self.__width, items_size_needed)
    self.adjustSize()

    Can anyone explain to me, what's wrong in my understanding?

  2. The following user says thank you to miso for this useful post:


Similar Threads

  1. Replies: 3
    Last Post: 11th December 2011, 10:09
  2. Replies: 1
    Last Post: 9th May 2011, 20:45
  3. Replies: 1
    Last Post: 1st May 2010, 23:03
  4. QListView
    By Yayati.Ekbote in forum Qt Programming
    Replies: 2
    Last Post: 1st March 2010, 11:41
  5. Replies: 2
    Last Post: 22nd January 2008, 16:10

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.