1+ // clang-format off
12/* ****************************************************************/ /* *
23 * \file TestWidget.cpp
3- * \brief
4+ * \brief Implementation of the TestWidget class.
45 *
56 * \author Xuhua Huang
67 * \date February 11, 2021
78 *********************************************************************/
9+ // clang-format on
810
911#include " TestWidget.h"
1012
1113// TestWidget class constructor
1214// pointer parent is passed to parent class constructor
1315TestWidget::TestWidget (QWidget* parent)
14- : QWidget(parent) {
15- // instanciate a vertical box layout manager
16- QVBoxLayout* vbox = new QVBoxLayout ();
16+ : QWidget(parent) {
17+ // instanciate a vertical box layout manager
18+ QVBoxLayout* vbox = new QVBoxLayout ();
1719
18- // instantiate a label with "new" keyword and call QLabel constructor
19- label = new QLabel (" Hello Qt World" );
20- label->setFont (QFont (" Times New Roman" , 11 ));
20+ // instantiate a label with "new" keyword and call QLabel constructor
21+ label = new QLabel (" Hello Qt World" );
22+ label->setFont (QFont (" Times New Roman" , 11 ));
2123
22- // set the background to green and text to white
23- label->setStyleSheet (" QLabel { background-color : green; color : white; }" );
24+ // set the background to green and text to white
25+ label->setStyleSheet (" QLabel { background-color : green; color : white; }" );
2426
25- // create a new label to implement very first hyperlink
26- QLabel* label2 = new QLabel ();
27- showHyperlink (label2); // call function
27+ // create a new label to implement very first hyperlink
28+ label2 = new QLabel ();
29+ showHyperlink (label2); // call function
2830
29- // add the label to the layout manager
30- vbox->addWidget (label);
31- vbox->addWidget (label2); // label2 still exists since it is a pointer
31+ // add the label to the layout manager
32+ vbox->addWidget (label);
33+ vbox->addWidget (label2); // label2 still exists since it is a pointer
3234
33- // notice that there can only be one setLayout(): at the end of the
34- // constructor
35- this ->setLayout (vbox);
35+ // notice that there can only be one setLayout(): at the end of the
36+ // constructor
37+ this ->setLayout (vbox);
3638}
3739
3840// TestWidget class destructor is empty since
@@ -42,8 +44,8 @@ TestWidget::~TestWidget() noexcept {
4244
4345// content modified by function will stay since it is passed the address
4446void TestWidget::showHyperlink (QLabel* const label) {
45- label->setText (" <a href=\" www.qt-project.org/\" >Get Started With Qt</a>" );
46- label->setTextFormat (Qt::RichText);
47- label->setTextInteractionFlags (Qt::TextBrowserInteraction);
48- label->setOpenExternalLinks (true );
47+ label->setText (" <a href=\" www.qt-project.org/\" >Get Started With Qt</a>" );
48+ label->setTextFormat (Qt::RichText);
49+ label->setTextInteractionFlags (Qt::TextBrowserInteraction);
50+ label->setOpenExternalLinks (true );
4951}
0 commit comments