samedi 29 octobre 2016

can i show a child QWidget on Parental QWidget without layout

/* Qt Code Example for embedding a child in parent and showing it as an Overlay without using a Layout */

    #include "widget.h"
    #include <QApplication>

    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        Widget w; // parent
        w.setStyleSheet("background-color:blue");

        Widget w1; // child Widget w1(&w),
        w1.setParent(&w);
        w1.setStyleSheet("background-color:red");
        w1.setGeometry(400,300,100,100); // i tried many other options as well 
        w1.show();
        w1.setVisible(true);    
        w.show();    
        return a.exec();
    }



I can only see the blue background of parent .
Red Child is  nowhere seen.

Aucun commentaire:

Enregistrer un commentaire