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.cpp

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

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

    }
    void MainWindow::open(){
    AnotherMainWindow * w2 = new AnotherMainWindow(this);
    w2->show();
    //w2.showFullScreen();
    //this->hide();

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

    //main.cpp

    w.showMaximized();



  • 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
 

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