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. Signal slot confusion
Qt 6.11 is out! See what's new in the release blog

Signal slot confusion

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 868 Views 1 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.
  • B Offline
    B Offline
    beetroot
    wrote on last edited by
    #1

    Hi
    I have a main window class that makes use of another class services (for example loading of a configuration file).
    My question regards how best to set up the communication between the two classes.
    At the moment I am creating the connections is the Main Window class -
    @
    connect(this,&MainWindow::fileSelected,m_fileHandler,&FileManagement::FileManager::load);
    connect (m_fileManager,&FileManagement::FileManager::fileLoaded,this,&MainWindow::onfileLoaded);
    @
    I am wondering if this is the recommended way - rather than having the first connect statement in the FileManager class?
    The reason I have done this way is so that I do not have to include the header for Main window in FileManager.
    Are there any alternative approaches.

    I know this example seems trivial but in reality things are likely to be more complex and I want to get the design correct before it is too late

    Thanks for your time

    beetroot

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qxoz
      wrote on last edited by
      #2

      Well signal and slot mechanism is most recommended way for connecting between classes and it is definitely better than passing pointer of MainWindow to FileManagement.

      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