[Qt-interest] Changing font size in QTableWidgetItem

Paul England pengland at cmt-asia.com
Tue Jan 20 02:54:02 CET 2009



Malyushytsky, Alex wrote:
>>> 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);
>
>   

Thanks -- I will try this.

Why not set the font role on the model? 

Of course you would need a custom model, but if you can get away with a
tablewidget the model wont be too complex.


Model isn't going to work for this.  It's a very complex QTableWidget.  
Has data from multiple sockets, as well as user input.
> 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."
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>   



More information about the Qt-interest-old mailing list