Important: Please read the Qt Code of Conduct -

QT Newbie ( how to open widget from mainwindow )

  • I am a Newbie in Qt and i want to know that "how to open widget from mainwindow" Can any one provide the code
    i have write some code but widget are not disp--layed.

    Thanks in Advance


    MainWindow::MainWindow(QWidget *parent) :
    ui(new Ui::MainWindow)

    QLabel *label = new QLabel("Name:");
    //QLineEdit *lineEdit = new QLineEdit();
    QHBoxLayout *layout = new QHBoxLayout();
    layout->addWidget(label , 0, 0);

    void MainWindow::open(){
    AnotherMainWindow * w2 = new AnotherMainWindow(this);

    //MainWindow.h( i have added in .h)
    public slots :
    void open() ;



  • hi syed,
    there are a whole bunch of examples in the Qt installation folder with sources, try to run one of them and walk through the code, you will be able to solve this on your own :)
    Also can you markup your code by enclosing them within @ tags, easier to read

Log in to reply