|
yafeilinux 发表于 2013-7-7 10:25
你要实现什么样的效果呢?按下一个open,打开一个新的窗口,就像一个对话框那样的吗?
如果是这样的话,直 ... - #include<QtGui>
- #include "mytest.h"
- QHBoxLayout *mainLayout = new QHBoxLayout;
- myTest::myTest(QWidget *parent)
- : QDialog(parent)
- {
- QWidget *widget = new QWidget(parent);
- label = new QLabel(tr("Open a window"));
- openButton = new QPushButton(tr("open"));
- closeButton = new QPushButton(tr("close"));
- connect(openButton,SIGNAL(clicked()),this,SLOT(openclicked()));
- connect(closeButton,SIGNAL(clicked()),this,SLOT(close()));
- QVBoxLayout *rightLayout = new QVBoxLayout;
- rightLayout->addWidget(openButton);
- rightLayout->addWidget(closeButton);
-
- mainLayout->addWidget(label);
- mainLayout->addLayout(rightLayout);
- setLayout(mainLayout);
- setWindowTitle(tr("Use Open"));
- setFixedHeight(sizeHint().height());
-
- }
- void myTest::openClicked()
- {
-
- QDialog *dialog = new QDialog();
- dialog->setWindowTitle(tr("a new window"));
- dialog->show();
- }
复制代码 |
|