mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-05 16:55:25 +08:00
qt 6.5.1 original
This commit is contained in:
1
examples/widgets/tutorials/gettingStarted/CMakeLists.txt
Normal file
1
examples/widgets/tutorials/gettingStarted/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
add_subdirectory(gsQt)
|
@ -0,0 +1,4 @@
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS += dir_gsqt
|
||||
|
||||
dir_gsqt.file = gsQt/gsqt.pro
|
@ -0,0 +1,8 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
qt_internal_add_example(part1)
|
||||
qt_internal_add_example(part2)
|
||||
qt_internal_add_example(part3)
|
||||
qt_internal_add_example(part4)
|
||||
qt_internal_add_example(part5)
|
7
examples/widgets/tutorials/gettingStarted/gsQt/gsqt.pro
Normal file
7
examples/widgets/tutorials/gettingStarted/gsQt/gsqt.pro
Normal file
@ -0,0 +1,7 @@
|
||||
TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS = part1 \
|
||||
part2 \
|
||||
part3 \
|
||||
part4 \
|
||||
part5
|
@ -0,0 +1,36 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(getting_started_part1 LANGUAGES CXX)
|
||||
|
||||
if(NOT DEFINED INSTALL_EXAMPLESDIR)
|
||||
set(INSTALL_EXAMPLESDIR "examples")
|
||||
endif()
|
||||
|
||||
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/gettingStarted/gsQt/part1")
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
|
||||
|
||||
qt_standard_project_setup()
|
||||
|
||||
qt_add_executable(getting_started_part1
|
||||
main.cpp
|
||||
)
|
||||
|
||||
set_target_properties(getting_started_part1 PROPERTIES
|
||||
WIN32_EXECUTABLE TRUE
|
||||
MACOSX_BUNDLE TRUE
|
||||
)
|
||||
|
||||
target_link_libraries(getting_started_part1 PRIVATE
|
||||
Qt6::Core
|
||||
Qt6::Gui
|
||||
Qt6::Widgets
|
||||
)
|
||||
|
||||
install(TARGETS getting_started_part1
|
||||
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
)
|
@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QTextEdit textEdit;
|
||||
textEdit.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
|
||||
QT += widgets
|
||||
SOURCES = main.cpp
|
||||
|
||||
# install
|
||||
target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tutorials/gettingStarted/gsQt/part1
|
||||
INSTALLS += target
|
||||
|
@ -0,0 +1,36 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(getting_started_part2 LANGUAGES CXX)
|
||||
|
||||
if(NOT DEFINED INSTALL_EXAMPLESDIR)
|
||||
set(INSTALL_EXAMPLESDIR "examples")
|
||||
endif()
|
||||
|
||||
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/gettingStarted/gsQt/part2")
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
|
||||
|
||||
qt_standard_project_setup()
|
||||
|
||||
qt_add_executable(getting_started_part2
|
||||
main.cpp
|
||||
)
|
||||
|
||||
set_target_properties(getting_started_part2 PROPERTIES
|
||||
WIN32_EXECUTABLE TRUE
|
||||
MACOSX_BUNDLE TRUE
|
||||
)
|
||||
|
||||
target_link_libraries(getting_started_part2 PRIVATE
|
||||
Qt6::Core
|
||||
Qt6::Gui
|
||||
Qt6::Widgets
|
||||
)
|
||||
|
||||
install(TARGETS getting_started_part2
|
||||
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
)
|
@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QTextEdit *textEdit = new QTextEdit;
|
||||
QPushButton *quitButton = new QPushButton("&Quit");
|
||||
|
||||
QObject::connect(quitButton, &QPushButton::clicked,
|
||||
qApp, &QApplication::quit);
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->addWidget(textEdit);
|
||||
layout->addWidget(quitButton);
|
||||
|
||||
QWidget window;
|
||||
window.setLayout(layout);
|
||||
|
||||
window.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
|
||||
QT += widgets
|
||||
SOURCES = main.cpp
|
||||
|
||||
# install
|
||||
target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tutorials/gettingStarted/gsQt/part2
|
||||
INSTALLS += target
|
||||
|
@ -0,0 +1,36 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(getting_started_part3 LANGUAGES CXX)
|
||||
|
||||
if(NOT DEFINED INSTALL_EXAMPLESDIR)
|
||||
set(INSTALL_EXAMPLESDIR "examples")
|
||||
endif()
|
||||
|
||||
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/gettingStarted/gsQt/part3")
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
|
||||
|
||||
qt_standard_project_setup()
|
||||
|
||||
qt_add_executable(getting_started_part3
|
||||
main.cpp
|
||||
)
|
||||
|
||||
set_target_properties(getting_started_part3 PROPERTIES
|
||||
WIN32_EXECUTABLE TRUE
|
||||
MACOSX_BUNDLE TRUE
|
||||
)
|
||||
|
||||
target_link_libraries(getting_started_part3 PRIVATE
|
||||
Qt6::Core
|
||||
Qt6::Gui
|
||||
Qt6::Widgets
|
||||
)
|
||||
|
||||
install(TARGETS getting_started_part3
|
||||
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
)
|
@ -0,0 +1,61 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
class Notepad : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Notepad();
|
||||
|
||||
private slots:
|
||||
void quit();
|
||||
|
||||
private:
|
||||
QTextEdit *textEdit;
|
||||
QPushButton *quitButton;
|
||||
|
||||
};
|
||||
|
||||
Notepad::Notepad()
|
||||
{
|
||||
textEdit = new QTextEdit;
|
||||
quitButton = new QPushButton(tr("Quit"));
|
||||
|
||||
connect(quitButton, &QPushButton::clicked,
|
||||
this, &Notepad::quit);
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->addWidget(textEdit);
|
||||
layout->addWidget(quitButton);
|
||||
|
||||
setLayout(layout);
|
||||
|
||||
setWindowTitle(tr("Notepad"));
|
||||
}
|
||||
|
||||
void Notepad::quit()
|
||||
{
|
||||
QMessageBox messageBox;
|
||||
messageBox.setWindowTitle(tr("Notepad"));
|
||||
messageBox.setText(tr("Do you really want to quit?"));
|
||||
messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
messageBox.setDefaultButton(QMessageBox::No);
|
||||
if (messageBox.exec() == QMessageBox::Yes)
|
||||
qApp->quit();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
Notepad notepad;
|
||||
notepad.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#include "main.moc"
|
||||
|
@ -0,0 +1,8 @@
|
||||
|
||||
QT += widgets
|
||||
SOURCES = main.cpp
|
||||
|
||||
# install
|
||||
target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tutorials/gettingStarted/gsQt/part3
|
||||
INSTALLS += target
|
||||
|
@ -0,0 +1,36 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(getting_started_part4 LANGUAGES CXX)
|
||||
|
||||
if(NOT DEFINED INSTALL_EXAMPLESDIR)
|
||||
set(INSTALL_EXAMPLESDIR "examples")
|
||||
endif()
|
||||
|
||||
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/gettingStarted/gsQt/part4")
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
|
||||
|
||||
qt_standard_project_setup()
|
||||
|
||||
qt_add_executable(getting_started_part4
|
||||
main.cpp
|
||||
)
|
||||
|
||||
set_target_properties(getting_started_part4 PROPERTIES
|
||||
WIN32_EXECUTABLE TRUE
|
||||
MACOSX_BUNDLE TRUE
|
||||
)
|
||||
|
||||
target_link_libraries(getting_started_part4 PRIVATE
|
||||
Qt6::Core
|
||||
Qt6::Gui
|
||||
Qt6::Widgets
|
||||
)
|
||||
|
||||
install(TARGETS getting_started_part4
|
||||
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
)
|
@ -0,0 +1,73 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
class Notepad : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Notepad();
|
||||
|
||||
private slots:
|
||||
void load();
|
||||
void save();
|
||||
|
||||
private:
|
||||
QTextEdit *textEdit;
|
||||
|
||||
QAction *loadAction;
|
||||
QAction *saveAction;
|
||||
QAction *exitAction;
|
||||
|
||||
QMenu *fileMenu;
|
||||
};
|
||||
|
||||
Notepad::Notepad()
|
||||
{
|
||||
loadAction = new QAction(tr("&Load"), this);
|
||||
saveAction = new QAction(tr("&Save"), this);
|
||||
exitAction = new QAction(tr("E&xit"), this);
|
||||
|
||||
connect(loadAction, &QAction::triggered,
|
||||
this, &Notepad::load);
|
||||
connect(saveAction, &QAction::triggered,
|
||||
this, &Notepad::save);
|
||||
connect(exitAction, &QAction::triggered,
|
||||
qApp, &QApplication::quit);
|
||||
|
||||
fileMenu = menuBar()->addMenu(tr("&File"));
|
||||
fileMenu->addAction(loadAction);
|
||||
fileMenu->addAction(saveAction);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(exitAction);
|
||||
|
||||
textEdit = new QTextEdit;
|
||||
setCentralWidget(textEdit);
|
||||
|
||||
setWindowTitle(tr("Notepad"));
|
||||
}
|
||||
|
||||
void Notepad::load()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Notepad::save()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
Notepad notepad;
|
||||
notepad.show();
|
||||
|
||||
return app.exec();
|
||||
};
|
||||
|
||||
#include "main.moc"
|
||||
|
@ -0,0 +1,8 @@
|
||||
|
||||
QT += widgets
|
||||
SOURCES = main.cpp
|
||||
|
||||
# install
|
||||
target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tutorials/gettingStarted/gsQt/part4
|
||||
INSTALLS += target
|
||||
|
@ -0,0 +1,36 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(getting_started_part5 LANGUAGES CXX)
|
||||
|
||||
if(NOT DEFINED INSTALL_EXAMPLESDIR)
|
||||
set(INSTALL_EXAMPLESDIR "examples")
|
||||
endif()
|
||||
|
||||
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/gettingStarted/gsQt/part5")
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
|
||||
|
||||
qt_standard_project_setup()
|
||||
|
||||
qt_add_executable(getting_started_part5
|
||||
main.cpp
|
||||
)
|
||||
|
||||
set_target_properties(getting_started_part5 PROPERTIES
|
||||
WIN32_EXECUTABLE TRUE
|
||||
MACOSX_BUNDLE TRUE
|
||||
)
|
||||
|
||||
target_link_libraries(getting_started_part5 PRIVATE
|
||||
Qt6::Core
|
||||
Qt6::Gui
|
||||
Qt6::Widgets
|
||||
)
|
||||
|
||||
install(TARGETS getting_started_part5
|
||||
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
)
|
@ -0,0 +1,99 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
class Notepad : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Notepad();
|
||||
|
||||
private slots:
|
||||
void open();
|
||||
void save();
|
||||
|
||||
private:
|
||||
QTextEdit *textEdit;
|
||||
|
||||
QAction *openAction;
|
||||
QAction *saveAction;
|
||||
QAction *exitAction;
|
||||
|
||||
QMenu *fileMenu;
|
||||
};
|
||||
|
||||
Notepad::Notepad()
|
||||
{
|
||||
openAction = new QAction(tr("&Load"), this);
|
||||
saveAction = new QAction(tr("&Save"), this);
|
||||
exitAction = new QAction(tr("E&xit"), this);
|
||||
|
||||
connect(openAction, &QAction::triggered,
|
||||
this, &Notepad::open);
|
||||
connect(saveAction, &QAction::triggered,
|
||||
this, &Notepad::save);
|
||||
connect(exitAction, &QAction::triggered,
|
||||
qApp, &QApplication::quit);
|
||||
|
||||
fileMenu = menuBar()->addMenu(tr("&File"));
|
||||
fileMenu->addAction(openAction);
|
||||
fileMenu->addAction(saveAction);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(exitAction);
|
||||
|
||||
textEdit = new QTextEdit;
|
||||
setCentralWidget(textEdit);
|
||||
|
||||
setWindowTitle(tr("Notepad"));
|
||||
}
|
||||
|
||||
void Notepad::open()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "",
|
||||
tr("Text Files (*.txt);;C++ Files (*.cpp *.h)"));
|
||||
|
||||
if (!fileName.isEmpty()) {
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Could not open file"));
|
||||
return;
|
||||
}
|
||||
QTextStream in(&file);
|
||||
textEdit->setText(in.readAll());
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
void Notepad::save()
|
||||
{
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), "",
|
||||
tr("Text Files (*.txt);;C++ Files (*.cpp *.h)"));
|
||||
|
||||
if (!fileName.isEmpty()) {
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
// error message
|
||||
} else {
|
||||
QTextStream stream(&file);
|
||||
stream << textEdit->toPlainText();
|
||||
stream.flush();
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
Notepad notepad;
|
||||
notepad.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#include "main.moc"
|
||||
|
@ -0,0 +1,8 @@
|
||||
QT += widgets
|
||||
requires(qtConfig(filedialog))
|
||||
SOURCES = main.cpp
|
||||
|
||||
# install
|
||||
target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tutorials/gettingStarted/gsQt/part5
|
||||
INSTALLS += target
|
||||
|
Reference in New Issue
Block a user