O'Reilly logo

Hands-On Embedded Programming with Qt by John Werner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a widget with Qt Creator/Designer

When we started working on Hello From Qt! in Chapter 2, Writing Your First Qt Application, we created our first widget, MainWindow:

MainWindow inherited from QMainWindow, which traces its ancestry back to QWidget. The Designer screen allowed us to populate MainWindow with different predefined widgets.

There are actually three files associated with MainWindow:

  • MainWindow.h defines the MainWindow C++ class
  • MainWindow.cc (or .cpp) provides the implementation of MainWindow
  • MainWindow.ui defines the graphic elements (widgets) that make up the display of MainWindow

What if we want to add a custom widget ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required