Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to use UI of one window to another window?
Forum Update on Monday, May 27th 2025

How to use UI of one window to another window?

Scheduled Pinned Locked Moved Solved General and Desktop
desktopuiofanothermultiplewindow
4 Posts 2 Posters 639 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.
  • A Offline
    A Offline
    Aahi
    wrote on last edited by
    #1

    let's say I have two windows main_window and second_window, In main window I have "ui->checkBox->setChecked(true);" in main_window constructor and in second window I have a push_button and I want to uncheck the checkBox of main_window using the push_button of second_window so Basically in second_window I want to do is "main_window::ui->checkBox->setChecked(false);"

    So how can I do that also I don't want to change the ui from private to public?

    goloviznin.kG 1 Reply Last reply
    0
    • A Aahi

      @goloviznin-k It didn;t work this is what I write

      connect(ui->pushButton, SIGNAL(&QPushButton::pressed),new MainWindow(), SLOT( &MainWindow::ui->checkBox->setChecked(false)));
      

      window1 = MainWindow
      window2 = enter_mail (don't ask why)

      It didn't uncheck the the checkBox from window1

      goloviznin.kG Offline
      goloviznin.kG Offline
      goloviznin.k
      wrote on last edited by
      #4

      @Aahi You don't have to use this old connection style. Remove SIGNAL and SLOT words.

      auto window2 = new MainWindow();
      
      connect(ui->pushButton, &QPushButton::pressed, window2, &MainWindow::some_slot_that_you_have_in_MainWindow_class);
      
      
      some_slot_that_you_have_in_MainWindow_class()
      {
          ui->checkBox->setChecked(false);
      }
      

      Something like that

      1 Reply Last reply
      2
      • A Aahi

        let's say I have two windows main_window and second_window, In main window I have "ui->checkBox->setChecked(true);" in main_window constructor and in second window I have a push_button and I want to uncheck the checkBox of main_window using the push_button of second_window so Basically in second_window I want to do is "main_window::ui->checkBox->setChecked(false);"

        So how can I do that also I don't want to change the ui from private to public?

        goloviznin.kG Offline
        goloviznin.kG Offline
        goloviznin.k
        wrote on last edited by
        #2

        @Aahi Hi,
        I think you need something like:

        connect(window2_button_reference, &QPushButton::pressed, window1_reference, &Window1ClassName::uncheck_slot_name);
        
        A 1 Reply Last reply
        0
        • goloviznin.kG goloviznin.k

          @Aahi Hi,
          I think you need something like:

          connect(window2_button_reference, &QPushButton::pressed, window1_reference, &Window1ClassName::uncheck_slot_name);
          
          A Offline
          A Offline
          Aahi
          wrote on last edited by
          #3

          @goloviznin-k It didn;t work this is what I write

          connect(ui->pushButton, SIGNAL(&QPushButton::pressed),new MainWindow(), SLOT( &MainWindow::ui->checkBox->setChecked(false)));
          

          window1 = MainWindow
          window2 = enter_mail (don't ask why)

          It didn't uncheck the the checkBox from window1

          goloviznin.kG 1 Reply Last reply
          0
          • A Aahi

            @goloviznin-k It didn;t work this is what I write

            connect(ui->pushButton, SIGNAL(&QPushButton::pressed),new MainWindow(), SLOT( &MainWindow::ui->checkBox->setChecked(false)));
            

            window1 = MainWindow
            window2 = enter_mail (don't ask why)

            It didn't uncheck the the checkBox from window1

            goloviznin.kG Offline
            goloviznin.kG Offline
            goloviznin.k
            wrote on last edited by
            #4

            @Aahi You don't have to use this old connection style. Remove SIGNAL and SLOT words.

            auto window2 = new MainWindow();
            
            connect(ui->pushButton, &QPushButton::pressed, window2, &MainWindow::some_slot_that_you_have_in_MainWindow_class);
            
            
            some_slot_that_you_have_in_MainWindow_class()
            {
                ui->checkBox->setChecked(false);
            }
            

            Something like that

            1 Reply Last reply
            2

            • Login

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