Qt4:QLabel を使う。


Qt4:百の定石


  • 絵を貼付ける。
    QLabel* picLabel ;
    QPixmap pixmap;
    pixmap.load("tt-logo.jpg") ;
    picLabel->setPixmap( pixmap ) ;
    picLabel->setAlignment(Qt::AlignCenter) ;
  • テキストのサイズや色を変える。
    QLabel* ed = new QLabel  ;
    ed->setFont(QFont( "Times", 18, QFont::Bold )) ;
    ed->setForegroundRole(QPalette::Button) ;
    QPalette p ;
    p.setColor(ed->foregroundRole(), QColor(200, 0, 0)) ;
    ed->setPalette(p) ;
    ed->setText("Good Thing GOing") ;

#include <QFont>
#include <QColor>
#include <QPalette>
#include <QLabel>
#include <QPixmap>