Creating a basic digital clock
It's time to create a new project, so we will create a Qt Widgets application named Fancy_Clock
.
Note
We won't utilize any Qt Quick knowledge in this chapter.
Now, change the window title to Fancy Clock
or any other name that you like. Then, the main window UI needs to be tailored because the clock is displayed at the top of the desktop. The menu bar, status bar, and toolbar are all removed. After that, we need to drag an LCD Number widget into centralWidget
. Next, change the layout of MainWindow
to LayOut Horizontally in order to autoresize the subwidget. The last thing that needs to be done to the UI file is to change frameShape to NoFrame under the QFrame column in the property of lcdNumber
. If you've done this right, you'll get a prototype of a digital clock, as shown here:
In order to update the LCD number display repeatedly, we have to make use of the QTimer
class to set up a timer that emits a signal repetitively. In addition to this...