Created
March 15, 2026 07:12
-
-
Save lxylxy123456/95652a463b8ff45aaf29ca6671f22aff to your computer and use it in GitHub Desktop.
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
| References: | |
| * <https://github.com/qt/qtbase/tree/6.8.2/examples/widgets/touch/knobs> | |
| * <https://code.videolan.org/videolan/vlc/-/blob/3.0.23-2/modules/gui/qt/components/info_panels.cpp> | |
| * <https://doc.qt.io/qt-6/index.html> | |
| * <https://doc.qt.io/qt-6/zh/index.html> | |
| Commands to build and run: | |
| ``` | |
| apt install g++ make cmake qt6-base-dev | |
| cmake -B build | |
| cmake --build build | |
| ./build/demo | |
| ``` |
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
| # Copyright (C) 2022 The Qt Company Ltd. | |
| # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause | |
| cmake_minimum_required(VERSION 3.16) | |
| project(demo LANGUAGES CXX) | |
| find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) | |
| qt_standard_project_setup() | |
| qt_add_executable(demo | |
| main.cpp | |
| ) | |
| set_target_properties(demo PROPERTIES | |
| WIN32_EXECUTABLE TRUE | |
| MACOSX_BUNDLE TRUE | |
| ) | |
| target_link_libraries(demo PRIVATE | |
| Qt6::Core | |
| Qt6::Gui | |
| Qt6::Widgets | |
| ) | |
| install(TARGETS demo | |
| BUNDLE DESTINATION . | |
| RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | |
| LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | |
| ) | |
| qt_generate_deploy_app_script( | |
| TARGET demo | |
| OUTPUT_SCRIPT deploy_script | |
| NO_UNSUPPORTED_PLATFORM_ERROR | |
| ) | |
| install(SCRIPT ${deploy_script}) |
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
| // Copyright (C) 2016 The Qt Company Ltd. | |
| // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause | |
| #include <QApplication> | |
| #include <QTableWidget> | |
| const char *data[4][2] = { | |
| {"Example A", "Qt is\na full\ndevelopment\nframework"}, | |
| {"Example B", "Qt is\na full\ndevelopment\nframework\n"}, | |
| {"Example C", "Qt 是\n一个完整\n的开发框架"}, | |
| {"Example D", "Qt 是\n一个完整\n的开发框架\n"}, | |
| }; | |
| int main(int argc, char **argv) | |
| { | |
| QApplication app(argc, argv); | |
| QTableWidget *table = new QTableWidget(NULL); | |
| table->setFixedSize(350, 450); | |
| table->setColumnCount(2); | |
| for (int i = 0; i < 4; i++) { | |
| table->insertRow(i); | |
| for (int j = 0; j < 2; j++) { | |
| QString qstring = QString::fromUtf8(data[i][j]); | |
| QTableWidgetItem *key = new QTableWidgetItem(qstring); | |
| table->setItem(i, j, key); | |
| } | |
| } | |
| table->resizeRowsToContents(); | |
| table->show(); | |
| return app.exec(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment