LoginUI::LoginUI(QWidget *parent) : QDialog(parent), ui(new Ui::LoginUI),mouse_press(false) { ui->setupUi(this); //美化窗体外观 this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); this->setMouseTracking(false); closeButton = new QToolButton(this); QPixmap closePix(":/icons/res/loginUI/close.png"); closeButton->setIcon(closePix); closeButton->setGeometry(width()-25,5,20,20); closeButton->setToolTip(tr("关闭")); closeButton->setStyleSheet("background-color:transparent;"); connect(closeButton,SIGNAL(clicked()),this,SLOT(close())); QPixmap pixmap = QPixmap(":/icons/res/loginUI/afternoon.jpg").scaled(this->size()); QPalette palette(this->palette()); palette.setBrush(QPalette::Background, QBrush(pixmap)); this->setPalette(palette); //中央显示 move ((QApplication::desktop()->width() - width())/2, (QApplication::desktop()->height() - height())/2); }
void Receiver::createWidget() { this->setMinimumHeight(150); this->setMinimumWidth(500); setAutoFillBackground(true); QPalette pa = palette(); pa.setColor(QPalette::Background,QColor(255, 255, 255)); this->setPalette(pa); #ifndef Q_OS_MAC setStyleSheet("QLineEdit{border: 2px groove rgb(211, 211, 211)} QDoubleSpinBox{border: 2px groove rgb(211, 211, 211);} QComboBox{border: 2px groove rgb(211, 211, 211);}"); #endif payTo->setToolTip(tr("输入地址")); payTo->setMinimumHeight(25); payTo->setMinimumWidth(370); QPixmap closePix(":icons/closesend"); closeButton = new YbLabelButton(closePix); QHBoxLayout *closeLayout = new QHBoxLayout; closeLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); closeLayout->addWidget(closeButton); // closeLayout->addSpacing(1); connect(closeButton, SIGNAL(labelButtonClicked()), this, SIGNAL(closeReceiver())); QPixmap addPix(":icons/addsend"); addButton = new YbLabelButton(addPix); QHBoxLayout *addLayout = new QHBoxLayout; addLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); addLayout->addWidget(addButton); addLayout->addSpacing(10); connect(addButton, SIGNAL(labelButtonClicked()), this, SIGNAL(addReceiver())); QLabel *receiverLabel = new QLabel(tr("receiver:")); QHBoxLayout *payToLayout = new QHBoxLayout; payToLayout->addSpacing(20); payToLayout->addWidget(receiverLabel); //payToLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); payToLayout->addWidget(payTo); payToLayout->addSpacing(33); payAmount->setMinimumHeight(25); payAmount->setMinimumWidth(370); QHBoxLayout *moneyLayout = new QHBoxLayout; //moneyLayout->addSpacing(); QLabel *moneyText = new QLabel(tr("money:")); moneyLayout->addSpacing(20); moneyLayout->addWidget(moneyText); moneyLayout->addSpacing(12); moneyLayout->addWidget(payAmount); moneyLayout->addSpacing(40); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(closeLayout); mainLayout->addLayout(payToLayout); mainLayout->addSpacing(20); mainLayout->addLayout(moneyLayout); mainLayout->addSpacing(10); mainLayout->addLayout(addLayout); mainLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding)); setLayout(mainLayout); }