按钮显示不出,是怎么回事
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
initUI();
createCornerBtn();
initAddDlg();
m_mydatabase=new CreateDb;
m_mydatabase->initDB(); //初始化数据库
onBtnRefresh(); //调用刷新按钮 其实就是重新查询数据库数据库
m_operateType=Add; //初始化操作类型为Add
ui->tabWidget->setStyleSheet("QTabBar::tab{min-width:30px;min-height:10ex}"); //设置tabbar的样式
}
Widget::~Widget()
{
delete ui;
}
void Widget::initUI()
{
setWindowTitle("学生管理系统");
m_pStuManager=new StuManager;
ui->tabWidget->addTab(m_pStuManager,"学生管理");
this->show();
}
void Widget::createCornerBtn()
{
QPushButton *btnFresh=new QPushButton("刷新");
QPushButton *btnAdd=new QPushButton("添加");
QPushButton *btnEdit=new QPushButton("编辑");
QPushButton *btnDel=new QPushButton("删除");
QWidget *cornerWidget=new QWidget;
QHBoxLayout *hLayout=new QHBoxLayout;
hLayout->addWidget(btnFresh);
hLayout->addWidget(btnAdd);
hLayout->addWidget(btnEdit);
hLayout->addWidget(btnDel);
cornerWidget->setLayout(hLayout);
ui->tabWidget->setCornerWidget(cornerWidget,Qt::TopRightCorner);
connect(btnFresh,&QPushButton::clicked,this,&Widget::onBtnRefresh);
connect(btnAdd,&QPushButton::clicked,this,&Widget::onBtnAdd);
connect(btnEdit,&QPushButton::clicked,this,&Widget::onBtnEdit);
connect(btnDel,&QPushButton::clicked,this,&Widget::onBtnDel);
}
现在结果:
理想结果: