diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index 8c6e80b..378569b 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -34,9 +34,21 @@ }, "pinned": true } + }, + { + "id": "90e723ca7b21bf9e", + "type": "leaf", + "state": { + "type": "markdown", + "state": { + "file": "04. Programming/QT/timer.md", + "mode": "source", + "source": true + } + } } ], - "currentTab": 1 + "currentTab": 2 } ], "direction": "vertical" @@ -94,7 +106,7 @@ "state": { "type": "backlink", "state": { - "file": "00. Inbox/01. TODO.md", + "file": "04. Programming/QT/timer.md", "collapseAll": false, "extraContext": false, "sortOrder": "alphabetical", @@ -119,7 +131,7 @@ "state": { "type": "outline", "state": { - "file": "00. Inbox/01. TODO.md" + "file": "04. Programming/QT/timer.md" } } }, @@ -170,10 +182,11 @@ "periodic-notes:Open today": false } }, - "active": "3b4577823cedf427", + "active": "90e723ca7b21bf9e", "lastOpenFiles": [ - "00. Inbox/想要的鏡頭.md", "00. Inbox/01. TODO.md", + "04. Programming/QT/timer.md", + "00. Inbox/想要的鏡頭.md", "05. 資料收集/Capture One.md", "04. Programming/OpenCV API.md", "04. Programming/OpenCV.md", @@ -201,7 +214,6 @@ "02. 工作/01. Logitech/00. OurTeam.md", "05. 資料收集/軟體工具/git/tag.md", "04. Programming/Kotlin/AtomicBoolean.md", - "03. 專注Study/Android/Android programming.md", "attachments/android_mediacodec_life_cycle.png", "attachments/android_mediacodec_flow.png", "attachments/Pasted image 20230308105856.png", diff --git a/04. Programming/QT/timer.md b/04. Programming/QT/timer.md new file mode 100644 index 0000000..44614b5 --- /dev/null +++ b/04. Programming/QT/timer.md @@ -0,0 +1,19 @@ +使用QTimer來反覆執行工作。 +QTimer可以單次執行,也可以多次執行。 + +使用概念如下: +1. 建立 QTimer 物件,例如叫做 timer。 +2. 連接QTimer的timeout signal到你的反應 function +3. 呼叫 timer->start() + +Example: +```cpp +QTimer* timer = new QTimer(this); +connect(timer, SIGNAL(timeout()), this, SLOT(update())); +timer->start(1000); +``` + +QTimer可以單次執行: +```cpp +QTimer::singleShot(200, this, SLOT(update()); +```