Warning, file /frameworks/kconfigwidgets/tests/kimageframe.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2009 Matthew Woehlke <mw_triad@users.sourceforge.net> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "kimageframe.h" 0008 #include <QPainter> 0009 #include <QStyle> 0010 #include <QStyleOption> 0011 0012 KImageFrame::KImageFrame(QWidget *parent) 0013 : QFrame(parent) 0014 , _w(0) 0015 , _h(0) 0016 { 0017 } 0018 0019 void KImageFrame::setImage(const QImage &img) 0020 { 0021 _img = img; 0022 _w = img.width(); 0023 _h = img.height(); 0024 update(); 0025 } 0026 0027 void KImageFrame::paintEvent(QPaintEvent *) 0028 { 0029 QPainter p(this); 0030 QStyleOptionFrame opt; 0031 QRect rf(frameRect()); 0032 QRect ri(0, 0, _w, _h); 0033 0034 opt.rect = rf; 0035 opt.state = QStyle::State_Sunken; 0036 0037 style()->drawPrimitive(QStyle::PE_Frame, &opt, &p, this); 0038 0039 ri.moveCenter(rf.center()); 0040 p.drawImage(ri, _img); 0041 0042 p.end(); 0043 }