[Qt-interest] Changing font size in QTableWidgetItem

Malyushytsky, Alex alex at wai.com
Tue Jan 20 00:41:41 CET 2009


>>tbl_main->item( row, col )->font().setPointSize( font_size );

Above code would not work cause you change a copy of the QFont object
Look at font () declaration: "QFont font () const;". You does not change the font used by item.

You should use setFont( ); as you did.

If you are going to make a lot of changes, try to disable widget update using QWidget::setUpdatesEnabled, this should improve performance:

setUpdatesEnabled(false);
bigVisualChanges();
setUpdatesEnabled(true);

Best regards,
   Alex

-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Paul England
Sent: Monday, January 19, 2009 3:21 PM
To: qt-interest at trolltech.com
Subject: [Qt-interest] Changing font size in QTableWidgetItem

Hi

Trying to change the font size of a QTableWidget (well, the
QTableWidgetItems in the QTableWidget).
Something like this works, but is painfully slow:

QFont f( "Tahoma", 10, QFont::Bold );
my_table->item( row, col )->setFont( f );

For a table of 18 rows and about 40-50 columns,  it takes a few seconds
to update.
I tried this:
tbl_main->item( row, col )->font().setPointSize( font_size );

Doesn't really work, unfortunately.  Do I have to repaint it or something?

Thanks
Paul
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."

"Please consider our environment before printing this email."




More information about the Qt-interest-old mailing list