Zeke Xiao

Zeke Xiao

github

Qt/C++ 代碼片段

Qt 遍歷文件夾#

#include <QCoreApplication>
#include <QDir>
#include <QFile>
#include <QtDebug>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QDir dir(a.applicationDirPath());
    dir.setFilter(QDir::Hidden | QDir::NoSymLinks);
    QFileInfoList file_list = dir.entryInfoList(QDir::Dirs);
    for(auto e: file_list){
        if(e.isDir()){
            QTextStream cout(stdout, QIODevice::WriteOnly);
            cout << e.fileName() << Qt::endl;
        }
    }
    return a.exec();
}

Qt 設置全局滑鼠樣式#

#include <QGuiApplication>

void foo(){
    QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
    doSomething();
    QGuiApplication::restoreOverrideCursor();
}

Qt/QML 帶圖示的按鈕 (Button)#

import QtQuick.Controls 2.15

Button {
    id: iconButton
    height: 30
    width: 30
    icon.source: "qrc:///images/delete.svg"
    icon.width: width
    icon.height: height
    icon.color: "transparent" //顯示圖示本身的顏色
}

Qt/QML 滑鼠可以選取的輸入框 (TextInput)#

import QtQuick 2.15
 
TextInput {
    id: input
    verticalAlignment: Qt.AlignVCenter
    text: "Please Input"
    selectByMouse: true
    MouseArea {
        anchors.fill: parent
        cursorShape: Qt.IBeamCursor
        acceptedButtons: Qt.NoButton
    }
}
``
載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。