This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cmake_minimum_required(VERSION 3.16) | |
| project(tt_client VERSION 0.1 LANGUAGES CXX) | |
| set(CMAKE_AUTOUIC ON) | |
| set(CMAKE_AUTOMOC ON) | |
| set(CMAKE_AUTORCC ON) | |
| set(CMAKE_CXX_STANDARD 17) | |
| set(CMAKE_CXX_STANDARD_REQUIRED ON) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| QString str("807F"); | |
| bool ok; | |
| short value = static_cast<short>(str.toUShort(&ok, 16)); | |
| qDebug() << value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| QOpenGLWidget | |
| 比如我们想要显示一张 QImage | |
| 我们可以用 QLabel 直接 setPixmap | |
| 也可以用 QGraphicsView 里设置一个 QGraphicsPixmapItem | |
| 但假如我们这张图需要不停刷新(30fps)并能随着控件大小缩放时 | |
| 特别是 4K 分辨率下,性能 就出现了瓶颈 | |
| 究其原因,还是 CPU 渲染慢,所以我们改用 GPU 来渲染 | |
| 自然,我们首先想到的是 QOpenGLWidget | |
| 下面是个保持图像 400x640 比例的类,m_x、m_y 代表横纵黑边的长度 | |
| glwidget.h |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //worker.h | |
| #pragma once | |
| #include <QObject> | |
| class Worker : public QObject | |
| { | |
| Q_OBJECT | |
| public: | |
| explicit Worker(QObject *parent = nullptr); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| echo "Installing OpenCV 4.5.2 on your Raspberry Pi 64-bit OS" | |
| echo "It will take minimal 1.5 hour !" | |
| cd ~ | |
| # install the dependencies | |
| sudo apt-get install -y build-essential cmake git unzip pkg-config | |
| sudo apt-get install -y libjpeg-dev libtiff-dev libpng-dev | |
| sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev | |
| sudo apt-get install -y libgtk2.0-dev libcanberra-gtk* libgtk-3-dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 单例模式 | |
| 很多人洋洋洒洒写了一大堆 | |
| 比如这里 http://xtuer.github.io/qtbook-singleton/ | |
| 比如这里 http://m.blog.csdn.net/Fei_Liu/article/details/69218935 | |
| 但是Qt本身就提供了专门的宏 Q_GLOBAL_STATIC | |
| 通过这个宏不但定义简单,还可以获得线程安全性。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| QHeaderView::section{ | |
| background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 #616161, stop: 0.5 #505050, stop: 0.6 #434343, stop:1 #656565); | |
| color: white; | |
| padding-left: 4px; | |
| border: 1px solid #6c6c6c; | |
| } | |
| QTableView{ | |
| gridline-color: white; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| QSlider::groove:horizontal{ | |
| height:8px; | |
| background-color:#646466; | |
| border-radius:4px; | |
| } | |
| QSlider::groove:horizontal:disabled{ | |
| background-color:#3c3d3e; | |
| } | |
| QSlider::handle:horizontal{ | |
| background-color:#878787; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| *{ | |
| outline: 0px; | |
| } | |
| QListWidget{ | |
| color: white; | |
| } | |
| QListWidget::item:selected{ | |
| background:#484c58; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <cstdint> | |
| int main() { | |
| uint8_t data[4] = {0xAA, 0xBB, 0xCC, 0xDD}; | |
| float result = 0.0f; | |
| for (int i = 0; i < 4; ++i) { | |
| result += static_cast<float>(data[i]) * (1 << (8 * i)); | |
| } | |
| std::cout << "Result: " << result << std::endl; | |
| return 0; |
NewerOlder