Qt
QT类
- 从Widget开始有了GUI界面(包括widget), widget是window-get的缩写(顾名思义, 从这里开始有了图形界面)
- QT中最常用的是QString类
- 对话框类: QFontDialog, QInputDialog
- Socket类: QTcpSocket, QUdpSocket
- 了解并体会QT框架中的家族图
工具链
- meego用于交叉编译
- uic用于将.ui转为.h文件
QT模拟器
常用的类
- QTabWidget
- QLabel: 有延迟, 调用repaint解决
- QTextEdit: 多行
- setText()
- clear()
- setFont()
- setFontColor()
- QLineEdit: 单行编辑器
- QPushButton
- QTableWidget
有下拉选项的
- QTreeWidget
- QListWidget
- QComboWidget
布局
- QHBoxLayout
- QVBoxLayout
从QAbstractButton
- QGroupBox
- QCheckBox
- QRadioButton
对话框
- QColorDialog
- QMessageBox
- QFileDialog
- QFontDialog
其他类
- QColor
- QColorDialog
- QFont
- QFontDialog
- QDateTime
MOC(基于Q_OBJECT宏)
- meta-object system
- meta-object compiler
菜单
- 里面的打开(&F)等为QAction
- 点击他们的信号为triggered信号
使用QPushButton
- 信号:
- pressed
- clicked
- released
QTextEdit
- textEdit->document()->isModified() -> 判断是否修改了
QString
- isEmpty()
- trimmed()
文件相关
QFile(父类为QIODevice)
- setFileName()
- QFile(name)
- exists()
- open(QIODevice::ReadOnly)
- close()
- readAll()
QDir
- currentPath()
QTextStream
- QTextString(QFileObject)
- readAll()
- close()
####### 打开文件
QFile *file = new QFile; file->setFileName(fileName); bool ok = file->open(QIODevice::ReadOnly); if (ok) { QTextStream in(file); in.readAll(); // 这里也可以直接私用file->readAll()但是QTextStream更快一点 in.close(); file->close(); } else { QMessageBox::information(this, "Error Message", "Open File Error!"); }
枚举
- Qt:: ->颜色
- QIODevice:: -> OpenMode
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步