Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QT Newbie ( how to open widget from mainwindow )

QT Newbie ( how to open widget from mainwindow )

Scheduled Pinned Locked Moved Mobile and Embedded
2 Posts 1 Posters 5.0k Views
  • 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 Offline
    S Offline
    syedasadalibs03
    wrote on last edited by
    #1

    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
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

      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
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved