Qt 没有ui,直接new一个button,为什么没有显示出来,但是确实占空间了,代码如下 5
classCWaitProgress:publicQDialog{Q_OBJECTpublic:CWaitProgress(QWidget*parent=0);~CWai...
class CWaitProgress : public QDialog
{
Q_OBJECT
public:
CWaitProgress(QWidget *parent = 0);
~CWaitProgress();
public:
void startProgress();
void stopProgress();
private:
QMovie *movie;
QLabel *label;
QPushButton *btn;
};
CWaitProgress::CWaitProgress(QWidget *parent /* = 0 */):QDialog(parent)
{
QVBoxLayout *layout=new QVBoxLayout();
btn = new QPushButton(this);
btn->setText("dddddddddddddd");
layout->addWidget(btn,0,Qt::AlignHCenter);
this->setLayout(layout);
} 展开
{
Q_OBJECT
public:
CWaitProgress(QWidget *parent = 0);
~CWaitProgress();
public:
void startProgress();
void stopProgress();
private:
QMovie *movie;
QLabel *label;
QPushButton *btn;
};
CWaitProgress::CWaitProgress(QWidget *parent /* = 0 */):QDialog(parent)
{
QVBoxLayout *layout=new QVBoxLayout();
btn = new QPushButton(this);
btn->setText("dddddddddddddd");
layout->addWidget(btn,0,Qt::AlignHCenter);
this->setLayout(layout);
} 展开
3个回答
展开全部
QPushButton *textButton = new QPushButton(tr("测试按钮"));
如此定义按钮
谢谢!
如此定义按钮
谢谢!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
layout->addWidget(btn,0,Qt::AlignHCenter);改成layout->addWidget(btn);试试
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询