Results 1 to 5 of 5

Thread: Simple Problem with QFont (point size)

  1. #1
    Join Date
    May 2007
    Location
    Warsaw, Poland
    Posts
    52
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Simple Problem with QFont (point size)

    Quick question.
    I want my QLabel present a text of 2pt size. I thought the code below would be correct. It is not as no matter what number I put instead of 2 the size stays the same (~12pt). How can I force smaller text?

    Qt Code:
    1. QFont mainHeaderFont("Helvetica [Cronyx]",2,QFont::Normal);
    2. mainHeader.setFont(mainHeaderFont);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Simple Problem with QFont (point size)

    Do you have "Helvetica [Cronyx]" installed?
    What happens if you simply use "Helvetica"?

    EDIT: Are you sure 2pt is a wise font size? Because at a resolution of 1680x1050 I can't even see a text with font size 2. Just tested it in Designer.
    Last edited by marcel; 31st December 2007 at 16:34.

  3. #3
    Join Date
    May 2007
    Location
    Warsaw, Poland
    Posts
    52
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Simple Problem with QFont (point size)

    Nothing.
    The problem is size, not the font family.
    I see ~12pt letters and I want it 2pt (or a bit bigger, anyway much smaller than what I see).

    The code:
    Qt Code:
    1. OrangeInquirer::OrangeInquirer(QWidget *parent) : QWidget(parent) {
    2. setFixedSize(300,300);
    3.  
    4. mainHeader.setText(tr("Your result will be saved as soon as\n you fill the input area and click ok."));
    5. qDebug(qPrintable(QString::number(mainHeader.fontInfo().pointSize())));
    6. //the code above shows always 9!!
    7. mainHeader.setParent(this);
    8. QFont mainHeaderFont("Helvetica",6,QFont::Normal);
    9. mainHeader.setFont(mainHeaderFont);
    10. qDebug(qPrintable(QString::number(mainHeader.fontInfo().pointSize())));
    11. //but the code above shows always 6 !! but the size does not change
    12. mainHeader.setGeometry(5+35+10,5+25+10,280-2*35-2*10,40);
    13. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by mtrpoland; 31st December 2007 at 16:49.

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Simple Problem with QFont (point size)

    what widget is mainHeader and in what context do you use it? i see it's created on the stack... or is it a member of some class?

  5. #5
    Join Date
    May 2007
    Location
    Warsaw, Poland
    Posts
    52
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Simple Problem with QFont (point size)

    mainLabel is a private member of OrangeInquirer

    I found
    Warning: Do not use this function in conjunction with Qt Style Sheets. The font of a widget can be customized using the "font" style sheet property.
    in QWidget::setFont(QFont &) doc...
    It does not say clearly that such combination would not work...
    Last edited by mtrpoland; 31st December 2007 at 16:58.

Similar Threads

  1. Simple custom widget won't size properly
    By MrGarbage in forum Qt Tools
    Replies: 2
    Last Post: 9th August 2007, 13:12

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.