#include "skinwidget.h"
#include<QSignalMapper>
#include<QtWidgets>
#include"mylabel.h"
skinwidget::skinwidget(QWidget *parent) : QWidget(parent)
{
signalMqpper = new QSignalMapper(this);
QStringList btnText;
btnText<<"1"<<"2"<<"3"<<"4";
QHBoxLayout *mainlayout = new QHBoxLayout;
for(int i=0;i<btnText.length();i++){
// QPushButton *btn= new QPushButton;
MyLabel *btn= new MyLabel;
QString qss="background-image:url(:/images/small_"+btnText[i]+".jpg)";
btn->setToolTip(btnText[i]);
btn->setStyleSheet(qss);
btn->setFixedSize(150,120);
//btn->setFlat(1);
btn->setScaledContents(1);
mainlayout->addWidget(btn);
QObject::connect(btn,SIGNAL(Clicked()),signalMqpper,SLOT(map()));
signalMqpper->setMapping(btn,btnText[i]);
}
connect(signalMqpper,SIGNAL(mapped(QString)),this,SIGNAL(skinChange(QString)));
MyLabel *skin_label = new MyLabel;
skin_label->setFixedSize(100,100);
skin_label->setPixmap(QPixmap(":/images/m_1.jpg"));
skin_label->setScaledContents(1);
QHBoxLayout *h= new QHBoxLayout;
h->addLayout(mainlayout);
h->addWidget(skin_label);
h->addSpacing(1);
h->addStretch(1);
setLayout(h);
setFixedSize(sizeHint().width(),sizeHint().height());
}