Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QT Newbie ( how to open widget from mainwindow )

    Mobile and Embedded
    1
    2
    4765
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      syedasadalibs03 last edited by

      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();

      1 Reply Last reply Reply Quote 0
      • ?
        Guest last edited by

        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

        1 Reply Last reply Reply Quote 0
        • First post
          Last post