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 reconnect signal to slot after object change?
Forum Updated to NodeBB v4.3 + New Features

How to reconnect signal to slot after object change?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 202 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.
  • R Offline
    R Offline
    Rozerchik
    wrote on last edited by Rozerchik
    #1

    I have a table in my project and a model attached to it. After I set new model to my table, my connection flies off and I need to create a new one. So, will it be right like this?

    void MainWindow::setNewModel()
    {
       disconnect(fileManager, &FileManager::setDefaultTableModel, this, &MainWindow::setNewTableModel);
       tableModel = new TableModel(this);
       ui->tableView->setModel(tableModel);
       connect(fileManager, &FileManager::setDefaultTableModel, this, &MainWindow::setNewTableModel);
    }
    
    Christian EhrlicherC 1 Reply Last reply
    0
    • R Rozerchik

      I have a table in my project and a model attached to it. After I set new model to my table, my connection flies off and I need to create a new one. So, will it be right like this?

      void MainWindow::setNewModel()
      {
         disconnect(fileManager, &FileManager::setDefaultTableModel, this, &MainWindow::setNewTableModel);
         tableModel = new TableModel(this);
         ui->tableView->setModel(tableModel);
         connect(fileManager, &FileManager::setDefaultTableModel, this, &MainWindow::setNewTableModel);
      }
      
      Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Rozerchik said in How to reconnect signal to slot after object change?:

      So, will it be right like this?

      Yes

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1

      • Login

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