QT5 代码创建控件示例
程序员文章站
2022-06-15 21:36:13
#include "mainwindow.h"#include #include #include #include #include #include #include #include #include
#include "mainwindow.h"
#include <QApplication>
#include <QPushButton>
#include <QLabel>
#include <QWidget>
#include <QTimer>
#include <QDateTime>
#include <QLayout>
#include <QLayoutItem>
#include <QAbstractItemModel>
#include <QAbstractItemView>
#include <QAbstractItemDelegate>
#include <QDockWidget>
#include <QStandardItemModel>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.setWindowTitle("控件");
w.show();
QWidget *window = new QWidget();
window->resize(240,320);
window->setWindowTitle("Widget");
// window->setWindowIcon();
window->show();
QLabel *label = new QLabel(window);
QDateTime *datatime = new QDateTime(QDateTime::currentDateTime());
label->setText(datatime->toString());
label->move(10, 5);
label->show();
QPushButton *btn1 = new QPushButton("OK",window);
btn1->move(20, 30);
btn1->show();
QStandardItemModel *model;
model = new QStandardItemModel(4, 2);
return a.exec();
}
本文地址:https://blog.csdn.net/u013420428/article/details/109644314