1. 程式人生 > >Qt按鈕部件簡單程式碼

Qt按鈕部件簡單程式碼

#include "mywidget.h"
#include "ui_mywidget.h"

#include<QApplication>
#include<QWidget>
#include<QLabel>
#include<QVBoxLayout>

QMyWidget::QMyWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::QMyWidget)
{
    ui->setupUi(this);
    QVBoxLayout* lay = new QVBoxLayout(this);
    QLabel*label;
    lay->addWidget(label=new QLabel("jsfhdsuhf"));
    label->setStyleSheet("QLabel {font:bold 16px;color:blue}");
}

QMyWidget::~QMyWidget()
{
    delete ui;
}