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
posted @ 2018-12-17 09:32  gogogo11  阅读(267)  评论(0编辑  收藏  举报