⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

Widget hiding other widget

  • Hi,

    Is there a way to set priority to the visibility of widget... like for instance if I have a frame with a picture and I want to put a button on top of the frame but I don't want to put it in the frame so that it doesn't inherit the stylesheet properties... I tried but the frame is hiding my button.. I want it the other way around.. what's under the button is hidden in the frame but the rest of the frame is still visible...

    Thanks good day

  • Could you please, show the code.

  • I don't do this manually.. it would be excruciating.. I use the designer

  • You are using widgets not QML, right?

    If I drop QPushPutton first and then QFrame above the button then right click on frame, "send to back" and the button always appear above the frame and accepts the mouse clicks.
    Check ui_*.h file and I see that my button belong to centralWidget
    pushButton_2 = new QPushButton(centralWidget);
    frame_2 = new QFrame(centralWidget);
    in the case when QFrame is first the button created like this
    frame_3 = new QFrame(centralWidget);
    pushButton_3 = new QPushButton(frame_3);

    Also you can redefine stylesheet properties for the button in a designer. See properties editor, QWidget, styleSheet.

    But maybe I did not get what is the problem is. :-)
    In this case could you please, show a picture of what you get and what you need.

  • Hi, I am not using QML you are right it is just regular widgets... I tried what you said and it is exactly what I was looking for thank you. I have another question if you don't mind... I have 2 qlabel that contains scalable pictures.. they are both in distinct horizontal layout.. now I want my app to be scalable so I have to put a mainlayout on the window.. problem is I want those 2 horizontal layout to overlap each other so that one image is on top of the other but I can't use a stackedlayout because both layouts must be visible at the same time... Is there a way to achieve this with regular layouts or I have to use QML and anchors.. if I put the smallest picture as a child of the background one the small one gets both background-image as a result of css inheriting... not sur if I made my problem clear..

    Anyways thanks for your time have a good day.

  • Glad that it worked for you.
    Regarding second question. It is not clear for me what you need to achieve.
    Could you post a picture of your design.

Log in to reply