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 Updated to NodeBB v4.3 + New Features

How to use UI of one window to another window?

Scheduled Pinned Locked Moved Solved General and Desktop
desktopuiofanothermultiplewindow
4 Posts 2 Posters 646 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.
  • A Offline
    A Offline
    Aahi
    wrote on 16 Jan 2022, 15:12 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?

    G 1 Reply Last reply 16 Jan 2022, 15:39
    0
    • A Aahi
      16 Jan 2022, 17:31

      @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

      G Offline
      G Offline
      goloviznin.k
      wrote on 16 Jan 2022, 17:52 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
        16 Jan 2022, 15:12

        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?

        G Offline
        G Offline
        goloviznin.k
        wrote on 16 Jan 2022, 15:39 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 16 Jan 2022, 17:31
        0
        • G goloviznin.k
          16 Jan 2022, 15:39

          @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 16 Jan 2022, 17:31 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

          G 1 Reply Last reply 16 Jan 2022, 17:52
          0
          • A Aahi
            16 Jan 2022, 17:31

            @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

            G Offline
            G Offline
            goloviznin.k
            wrote on 16 Jan 2022, 17:52 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

            2/4

            16 Jan 2022, 15:39

            • Login

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