Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to call secondary window from MainWindow class function
Qt 6.12 LTS is out! See what's new in the release blog

How to call secondary window from MainWindow class function

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 452 Views 2 Watching
  • 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.
  • J Offline
    J Offline
    JacobNovitsky
    wrote on last edited by
    #1

    void MainWindow::on_pushButton_clicked()
    {
    QuickPaste quickpaste;
    quickpaste.show();
    }

    code above would only work If I call a.exec for QApplication a(argc, argv) right after quickpaste.show();

    how do you guys manage this?

    I could imagine:
    pass QApplication a as an argument
    make it global
    use some C++ class features

    M 1 Reply Last reply
    0
    • J JacobNovitsky

      void MainWindow::on_pushButton_clicked()
      {
      QuickPaste quickpaste;
      quickpaste.show();
      }

      code above would only work If I call a.exec for QApplication a(argc, argv) right after quickpaste.show();

      how do you guys manage this?

      I could imagine:
      pass QApplication a as an argument
      make it global
      use some C++ class features

      M Offline
      M Offline
      mpergand
      wrote on last edited by mpergand
      #2

      @JacobNovitsky

      void MainWindow::on_pushButton_clicked()
      {
          QuickPaste* quickpaste=new QuickPaste();
          quickPaste->setAttribute(Qt::WA_DeleteOnClose);
          quickpaste->show();
      }
      
      1 Reply Last reply
      4

      • Login

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