Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946

How can I create QFrame on form ui?



  • How can I create QFrame by coding.
    and place it into form ui?

    Thanks



  • @
    #include "MainWindow.h"
    #include "ui_MainWindow.h"
    #include <QLayout>

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);

    QFrame *mFrame = new QFrame(this);
    mFrame->setGeometry(50, 50, 100, 100);
    mFrame->setStyleSheet("background-color:black;");
    
    this->layout()->addWidget(mFrame);
    

    }
    @



  • If I want to refer it in main.cpp not mainwindow.cpp
    how can I do?

    Thanks for answer


Log in to reply