[Solved] QFrame not showing up



  • I have a UI form called MonitorWindow. In its constructor, I instantiate a QWidget class called StatusBar. See the constructor code below:
    @
    MonitorWindow::MonitorWindow(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MonitorWindow)
    {
    ui->setupUi(this);

    StatusBar *statusBar = new StatusBar(this);
    

    }
    @
    Then, in the constructor for StatusBar, I set up the QFrame as folows:
    @
    StatusBar::StatusBar(QWidget *parent) :
    QWidget(parent)
    {
    QFrame *statusFrame = new QFrame(this);
    statusFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
    statusFrame->setLineWidth(1);
    statusFrame->resize(300, 42);
    statusFrame->move(0, 20);
    }
    @
    My MainWindow UI shows up with the other objects on it, but StatusBar doesn't show up at all. What am I doing wrong?



  • Try
    @
    ...
    StatusBar *statusBar = new StatusBar(this);
    statusBar->show();
    @



  • Unfortunately that doesn't make any difference.



  • You set a parent in the StatusBar widget. It's likely that it is hidden by the other widgets of your MainWindow. You should put it into a layout.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.