Custom QWidget
We now have to create the Task
class that will hold our data (task name and completed status). This class will have its form file separated from MainWindow
. Qt Creator provides an automatic tool to generate a base class and the associated form.
Click on File | New File or Project | Qt | Qt Designer Form Class. There are several form templates; you will recognize Main Window, which Qt Creator created for us when we started the todo
app project. Select Widget and name the class Task
, then click on Next. Here is a summary of what Qt Creator will do:
- Create a
Task.h
file and aTask.cpp
file. - Create the associated
Task.ui
and do the plumbing to connect it toTask.h
. - Add these three new files to
todo.pro
so they can be compiled.
Finish and, ...
Get Mastering Qt 5 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.