Qt-UI

Q Widget

Hands-on Qt | | Widget Size

Next we create a custom widget with a red background, by deriving from QWidget and telling its constructor to set a color palette with a single red color for the background.

class MyQWidget: public QWidget
{
public:

   //! default ctor
   MyQWidget(QWidget *parent = 0)
      : QWidget(parent)
   {
      QColor background="red";
      setPalette(background);
   }

   //! dtor
   ~MyQWidget()
   {}

};

Widgets can contain sub-widgets and so on. Therefore, the collection of all widgets is organized as a tree (or acyclic graph) with references to the parent widgets for each child.

Hands-on Qt | | Widget Size

Options: