Important: Please read the Qt Code of Conduct -

Moving Class into Widget

  • Thanks to this Forum I'm really making progress in QT-Developing. :)

    Now I'm facing a problem which is for me kinda difficult to understand. A colleague of mine developed a class which inherits from QWidget. The constructor also. It sets up a new interface but without using the QGroupBox(es) or QVBoxLayout(s) which are seen in most of the Tutorials.

    That's now kinda confusing for me. How am I able to move his interface inside one of these Container/Layout-Objects? None of the method-calls refer to the "parent"-parameter. As I understand it the QWidget is addressed directly always.

    The hpp:
    @class Warehousedisplay : public QWidget {
    //this and that...

    The cpp
    @Warehousedisplay::Warehousedisplay(QWidget* parent) : QWidget(parent)
    //and so on... but no usage of "parent"

    I've tried already to define a QFrame (because QFrame inherits directly from QWidget) which calls these methods (instead directly) - and afterwards put the QFrame inside a QVBoxLayout. But this didn't work at all as it should have. In fact my QVBoxLayout didn't appear at all, I've just taken the basic-functionality away...

    Also the constructor-inheritance doesn't seem to have an effect at all. The code returns the same result with or without it.

    What is a proper way to move these functionalities?
    Thank you!

  • Lifetime Qt Champion


    Can you provide an example of that class and how you are using it ?

Log in to reply