Results 1 to 8 of 8

Thread: QTable Column width supporting fonts

  1. #1
    Join Date
    Dec 2006
    Posts
    9
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QTable Column width supporting fonts

    I am working on the QTable which have the columns with specific sizes. So according to QFont and resolution of the system, I should display the column correctly fitting max characters per the column.

    There will be no scroll bar for the qtable because, I am working for QT/Embedded system which will not have mouse. Only touch screen is available.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTable Column width supporting fonts

    And what is the question?

  3. #3
    Join Date
    Dec 2006
    Posts
    9
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTable Column width supporting fonts

    I should display the column correctly fitting max characters per the column. How?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTable Column width supporting fonts

    I don't understand the question. Could you explain what you mean and what did you already try? What is the exact problem you are facing? Note, that this is not an outsourcing company website - we help you solve your problems, not solve your problems for you.

  5. #5
    Join Date
    Dec 2006
    Posts
    9
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTable Column width supporting fonts

    I want to display data in a spreadsheet like format on the screen.
    I used QTable to set columns and column widths.
    I have 5 columns.
    column1 has 7 as column width
    column2 has 30 as column width
    column3 has 36 as column width
    column4 has 30 as column width
    column5 has 30 as column width.

    But, with the specified font and font family, size, I should display the column width with label. There will be no scrollbar, no mouse.

    I had taken QFontMetrics fm(QApplication::fontmetrics());
    fontWidth=fm.width("W");//widest character width in pixels
    so for column1 = 7 * fm.width("W");
    But, it is going beyond screen limits for all the columns to display.

    please solve my problem. If you are not clear with this, please revert back.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTable Column width supporting fonts

    Hmm.. as far as I know "m" is the widest character. Remember that cells have margins, so if you want to display 7 characters, you need fm.width("m")*7 + 2*margin. But before you do that, take a look at QHeader::setStretchEnabled - if you enable stretch for all columns, they will scale when you resize the table.

  7. The following user says thank you to wysota for this useful post:

    kommu (27th December 2007)

  8. #7
    Join Date
    Dec 2006
    Posts
    9
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTable Column width supporting fonts

    I think W is the widest character. Since,
    fm.width("W") = 15 with font family set
    fm.width("M") = 13. with font family set

    Tried in the same way for M also. But it is not coming in the screen limits.
    As mentioned in previous mails, the characters are fitting into the columns, but QTable is not coming in the screen limits.

    If we use setColumnStrechable(true). All columns are resized equally and coming in the screen limits, but max characters of a column is not proper.

    The issue is with max characters per a column and QTable to come in screen limits.
    Last edited by kommu; 27th December 2007 at 06:49.

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTable Column width supporting fonts

    If the table is not wide enough then resize it according to the header width. See QTable::horizontalHeader().

Similar Threads

  1. QTable column stretchable with minimum Width
    By sunil.thaha in forum Qt Programming
    Replies: 0
    Last Post: 24th April 2006, 13:17

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.