Hacker News new | ask | show | jobs
by jcelerier 1863 days ago
Here's a quick port to Qt (except for the <> thing which I did not really understand after a cursory reading of its docs)

    #include <QtWidgets>

    int main(int argc, char **argv) {
      QApplication app{argc, argv};
      QWidget widg;
      QVBoxLayout form{&widg};

      QLabel label{
          R"(Hello, <span style="font-weight: 600; font-size: 16pt; color: blue;">Qt C++ Library</span>)"};

      QPushButton button{"Quit"};
      button.connect(&button, &QPushButton::clicked, [&widg] { widg.close(); });

      form.addStretch(0.1);
      form.addWidget(&label);
      form.addStretch(0.7);
      form.addWidget(&button);
      form.addStretch(0.2);

      widg.show();

      app.exec();
    }
Builds with

    g++ example.cpp -I/usr/include/qt/ -I/usr/include/qt/QtWidgets -fPIC -lQt5Widgets -lQt5Core
Here's also how the two programs behave in practice: https://streamable.com/brltmc

tl;ds: now that I saw it in action, I know I can instantly ignore anyone who says that nana is a suitable replacement for Qt.