[Qt-interest] QFont crashes?

Anatoly Burakov burakov.anatoly at googlemail.com
Sat Jul 18 14:32:51 CEST 2009


Frank Hemer wrote:
> On Saturday 18 July 2009 14:04:04 Anatoly Burakov wrote:
>> Hi all.
>>
>> I am trying to change font in QLineEdit. I get the font from QLineEdit,
>> change its height and put it back to QLineEdit like this:
>>
>> lineEdit = new QLineEdit;
>> QFont font = lineEdit->font();
>> font.setPointSize(15);
>> font.setBold(true);
>> lineEdit->setFont(font);
>>
>>
>>
>> this piece of code works perfectly.
>>
>> However, when i try to change the point size with a value from some
>> variable - program just exits with code 0:
>>
>> lineEdit = new QLineEdit;
>> int fontSize = 15;
>> QFont font = lineEdit->font();
>> font.setPointSize(fontSize);
>> font.setBold(true);
>> lineEdit->setFont(font);
>>
>> This code doesn't illustrate the need for a variable, but in reality i
>> am going to read that variable from an object holding application's
>> current settings (that is, change font size at user's preference).
> 
> Hmm - have you verified that:
> 1. The font supports pointSize (in oposite to pixelSize)?
> 2. Does the font support the fontSize you try to set ...
> 
> Frank
> 

The application exits even with that same code i wrote above - that is,
when i set point size to 15 - it works fine, but when i declare integer
variable, set it to 15 and set point size to that variable (which holds
value of 15) - application exits. I honestly can't see any valid reason
for QT to behave like this...

Best regards,
Anatoly





More information about the Qt-interest-old mailing list