一文搞定Swing和Qt按钮和文本框的创建
生活随笔
收集整理的這篇文章主要介紹了
一文搞定Swing和Qt按钮和文本框的创建
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一文搞定Swing和Qt按鈕和文本框的創建
- Qt的截圖
java的
源碼
Qt的
#ifndef WIDGET_H #define WIDGET_H#include <QWidget> #include <QLineEdit> namespace Ui { class Widget; }class Widget : public QWidget {Q_OBJECTpublic slots:public:explicit Widget(QWidget *parent = 0);~Widget();public slots:void alertMessage();private:Ui::Widget *ui;QLineEdit *edit; };#endif // WIDGET_H #include "widget.h" #include "ui_widget.h" #include <QMessageBox> #include <QPushButton> #include <QDebug> #include <QLineEdit>Widget::Widget(QWidget *parent) :QWidget(parent),ui(new Ui::Widget) {ui->setupUi(this);QPushButton *btn =new QPushButton;edit = new QLineEdit;edit->move(30,10);btn->setText("點我試一試");btn->setFixedSize(300,60);btn->move(QPoint(10,60));QObject::connect(btn,SIGNAL(clicked()),this,SLOT(alertMessage()) );btn->setParent(this);edit->setParent(this); } void Widget::alertMessage(){qDebug() << "123";qDebug() << edit->text(); }Widget::~Widget() {delete ui; }語法不一樣 ,實現思路類似。
總結
以上是生活随笔為你收集整理的一文搞定Swing和Qt按钮和文本框的创建的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: IOS开发地理编码与反向编码
- 下一篇: 开发者成功学:扔掉你那些很sexy的想法