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 from different classes

signal slot from different classes

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 847 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.
  • B Offline
    B Offline
    buildroot
    wrote on last edited by
    #1

    Hi everyone,

    I have two different classes,
    one of them has comboBox, another one has multiple page.
    I would like to change page with respect to selection of comboBox items.
    Have anyone idea, how can i do it?
    Thank you. (I am new to C++ and new to QT)

    Greetings

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Somewhere in your class hierarchy, these 2 classes certainly have some common parent (like a QMainWindow for example) - that's where you can connect the signals from combo box to your multipage widget.

      (Z(:^

      1 Reply Last reply
      4
      • B Offline
        B Offline
        buildroot
        wrote on last edited by
        #3

        Hi Sierdzio,
        thank you for fast answer. I assume i get it wrong. Should i implement the connect(..) in the parent class? because it will not see comboBox object. As said, i am new, maybe i am missing something.

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          Hi
          What @sierdzio means is that the best place to hook signal and slot up is where you know
          both classes have have access to the instances.
          Often that is mainwindow.

          So where you create the Selector (combo) and Pages class, there you can
          connect up so the selection in the combo can be hooked up to some slot that can flip the pages.

          Here is small example that has a tab widget on mainwindow and button that opens
          dialog and makes the tabwidget change page from dialog.
          https://www.dropbox.com/s/16rdw8g7zl6ie18/myotherdialog.zip?dl=0

          Note that i use exec() and not show() but works 100% the same.

          Since the combobox is private to the holding class, you just create a new public signal that
          the outside world can connect to. and maybe a new public slot for the pages class.

          1 Reply Last reply
          5

          • Login

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