C++ (Qt) QPixmap pix; pix.load(":/images/trt_logo.png"); logo->resize(pix.size()); logo->setPixmap(pix); logo->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); pix.load(":/images/about.png"); about->resize(pix.size()); about->setPixmap(pix); about->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
QPixmap pix1,pix2;
QPixmap pix; pix.load(":/images/trt_logo.png"); logo->setPixmap(pix.scaled(pix.size())); logo->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); pix.load(":/images/about.png"); about->setPixmap(pix.scaled(pix.size())); about->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
C++ (Qt)Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget){ ui->setupUi(this); QPixmap pix; pix = QApplication::style()->standardPixmap(QStyle::SP_BrowserStop); ui->label->setPixmap(pix); pix = QApplication::style()->standardPixmap(QStyle::SP_BrowserReload); ui->label_2->setPixmap(pix);}
C++ (Qt)Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget){ ui->setupUi(this); QPixmap pix; QPixmap temp; temp = QApplication::style()->standardPixmap(QStyle::SP_BrowserReload); pix = QApplication::style()->standardPixmap(QStyle::SP_BrowserStop); ui->label->setPixmap(pix); QByteArray bytes; QBuffer buffer(&bytes); buffer.open(QIODevice::WriteOnly); temp.save(&buffer, "PNG"); pix.loadFromData(bytes, "PNG"); ui->label_2->setPixmap(pix);}
C++ (Qt)// вставить перед loadpix.fill(Qt::transparent);
C++ (Qt)#include <QtCore/QBuffer> #include <QtGui/QApplication>#include <QtGui/QGridLayout>#include <QtGui/QStyle>#include <QtGui/QPixmap>#include <QtGui/QLabel> int main(int argc, char* argv[]){ QApplication a(argc, argv); QWidget mainWidget; QGridLayout layout(&mainWidget); QLabel label1(&mainWidget); QLabel label2(&mainWidget); layout.addWidget(&label1, 1, 1); layout.addWidget(&label2, 1, 2); QPixmap pix; QPixmap temp; temp = QApplication::style()->standardPixmap(QStyle::SP_BrowserReload); pix = QApplication::style()->standardPixmap(QStyle::SP_BrowserStop); label1.setPixmap(pix); QByteArray bytes; QBuffer buffer(&bytes); buffer.open(QIODevice::WriteOnly); temp.save(&buffer, "PNG"); #if 0 // set 1 for fix pix.fill(Qt::transparent);#endif pix.loadFromData(bytes, "PNG"); label2.setPixmap(pix); mainWidget.show(); return a.exec();}