下列方法是在ToolButton上設定圖片。

void CLoadImage::m_s_ToolButtonLoadImage(QString sFileName
,QToolButton *button)
{
    QImage *imgTmp=new QImage;
    if(!imgTmp->load(sFileName))return;
    button->setIconSize(QSize(imgTmp->width(),imgTmp->height()));
    button->setIcon(QPixmap::fromImage(*imgTmp));
    delete imgTmp;
}

imgTmp->load(QString )
是將檔案路徑上的圖片讀取進來。


arrow
arrow
    全站熱搜

    力寶 發表在 痞客邦 留言(0) 人氣()