1
votes

With Qt 4.8, I have :

  • a main window (QMainWindow);
  • a central widget setCentralWidget(x), x beeing a QLabel that contains an image;
  • another widget "B": a QLabel that contains an image

My problem is that the widget B is hidden under the central widget. How could I raise the widget B in the foreground ?

I know that B is hidden under the central widget because sometimes when B is placed on the left, and the image of the central widget is small enough, I can see a part of B.

2

2 Answers

2
votes

You can use B.raise() in order to increase z-index of B widget.

Raises this widget to the top of the parent widget's stack. After this call the widget will be visually in front of any overlapping sibling widgets.

1
votes

You could also attach "B" as a child of the central widget, or a child of widget X. This should then show on top.

QWidget B = new QWidget(x);

Alternatively, use a layout and add that to the central widget, with widgets x and B added to the layout. For example: -

QHBoxLayout* pLayout = new QHBoxLayout();
pLayout->addWidget(B);
pLayout->addWidget(x);

pMainWindow->setCentralWidget(pLayout);