diff --git a/digitalclock/CMakeLists.txt b/digitalclock/CMakeLists.txt new file mode 100644 index 0000000..405dde5 --- /dev/null +++ b/digitalclock/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 3.16) + +project(DigitalClock LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + + +find_package(QT NAMES Qt5 dirCOMPONENTS Widgets LinguistTools Network REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets LinguistTools Network REQUIRED) + +message(STATUS "Building DigitalClock with Qt ${QT_VERSION}") + + +set(SOURCES + digitalclock.cpp + ) + + +add_library(DigitalClock ${SOURCES} ) + +set_property(TARGET DigitalClock PROPERTY CXX_STANDARD 17) +set_property(TARGET DigitalClock PROPERTY CXX_STANDARD_REQUIRED ON) + +target_link_libraries(DigitalClock PRIVATE Qt${QT_VERSION_MAJOR}::Widgets ) + + + +# We export this information so that other projects can use it +set(${PROJECT_NAME}_INCLUDE_DIRS ${PROJECT_SOURCE_DIR} CACHE INTERNAL "${PROJECT_NAME}: Include directories" FORCE) +set(${PROJECT_NAME}_LIB_DIRS ${PROJECT_BINARY_DIR} CACHE INTERNAL "${PROJECT_NAME}: Library directories" FORCE) diff --git a/digitalclock/digitalclock.cpp b/digitalclock/digitalclock.cpp index 4b65b6b..2b130ec 100644 --- a/digitalclock/digitalclock.cpp +++ b/digitalclock/digitalclock.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -38,10 +48,11 @@ ** ****************************************************************************/ -#include - #include "digitalclock.h" +#include +#include + //! [0] DigitalClock::DigitalClock(QWidget *parent) : QLCDNumber(parent) @@ -49,7 +60,7 @@ DigitalClock::DigitalClock(QWidget *parent) setSegmentStyle(Filled); QTimer *timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(showTime())); + connect(timer, &QTimer::timeout, this, &DigitalClock::showTime); timer->start(1000); showTime(); diff --git a/digitalclock/digitalclock.h b/digitalclock/digitalclock.h index f891335..31c12f3 100644 --- a/digitalclock/digitalclock.h +++ b/digitalclock/digitalclock.h @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -49,7 +59,7 @@ class DigitalClock : public QLCDNumber Q_OBJECT public: - DigitalClock(QWidget *parent = 0); + DigitalClock(QWidget *parent = nullptr); private slots: void showTime(); diff --git a/digitalclock/digitalclock.pro b/digitalclock/digitalclock.pro index 6d2d283..4e4bc0f 100644 --- a/digitalclock/digitalclock.pro +++ b/digitalclock/digitalclock.pro @@ -1,23 +1,9 @@ -TEMPLATE = lib -DESTDIR = .. - -TARGET = digitalclock - -CONFIG += qt release warn_on build_all staticlib - -QT += core gui - -MOC_DIR = ../.moc - -OBJECTS_DIR = ../.objs -TARGET = digitalclock - -DEFINES += HAVE_POSIX_OPENPT -#or DEFINES += HAVE_GETPT - -HEADERS = digitalclock.h - -SOURCES = digitalclock.cpp - +QT += widgets +HEADERS = digitalclock.h +SOURCES = digitalclock.cpp \ + main.cpp +# install +target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/digitalclock +INSTALLS += target diff --git a/digitalclock/main.cpp b/digitalclock/main.cpp new file mode 100644 index 0000000..9440a81 --- /dev/null +++ b/digitalclock/main.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "digitalclock.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + DigitalClock clock; + clock.show(); + return app.exec(); +}