求一个例子程序~~~
谢谢刚才各位的帮助,可惜刚接触Qt才2,3天,还是不能完全理解各位的意思~~~
还是求哪位大神不吝给个例子程序吧,还是刚才要实现的那个功能,在一个窗口上有一个按钮(最好能控制按钮在窗口的位置),然后点击button会弹出一个dialog来~~
ps:或者哪位大神可以稍微修改下我的程序,让这个能跑通,实现这个简单的功能~
头文件mainwindow.h:#ifndef MAINWINDOW_H#define MAINWINDOW_H#include <QtGui>#include <QMainWindow>namespace Ui { class MainWindow;}class MainWindow : public QMainWindow{ Q_OBJECTpublic: explicit MainWindow(QWidget *parent = 0); ~MainWindow();private slots: void open();private: Ui::MainWindow *ui; QPushButton *button; QDialog *dialog;};#endif // MAINWINDOW_H源文件mainwin.cpp:#include "mainwindow.h"#include "ui_mainwindow.h"#include <QtGui>MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); QPushButton *button =new QPushButton("Open"); //button->setCheckable(true); QObject::connect(button, SIGNAL(clicked()), this, SLOT(open())); QGridLayout *layout = new QGridLayout; layout->addWidget(button,0,0); setLayout(layout);}MainWindow::~MainWindow(){ delete ui;}void MainWindow::open() { dialog->show(); }主函数main.cpp:#include <QtGui/QApplication>#include "mainwindow.h"#include <QtGui>int main(int argc, char *argv[]){ QApplication a(argc, argv); MainWindow w; w.show(); return a.exec();}