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 properly connect two widgets between two windows

How properly connect two widgets between two windows

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

    I have a MainWindow with lots of MyLabels showing images.

    And a SettingDialog with two buttons.

    I want trigger some slot of MyLabel by clicking buttons in SettingDialog.

    I tried use signal slot chain,that is ,when signal trig a slot,the slot do nothing but emit signal to upper layer.

    Its bad idea,because it must ensure every connections is connect right on sig slot chain

    And naming the signal slot pair also painful.

    What's a proper or standard, clean way to connect two widgets between two windows, if widgets are private to each other?

    Thank you.

    JonBJ 1 Reply Last reply
    0
    • P pachisuro4096

      I have a MainWindow with lots of MyLabels showing images.

      And a SettingDialog with two buttons.

      I want trigger some slot of MyLabel by clicking buttons in SettingDialog.

      I tried use signal slot chain,that is ,when signal trig a slot,the slot do nothing but emit signal to upper layer.

      Its bad idea,because it must ensure every connections is connect right on sig slot chain

      And naming the signal slot pair also painful.

      What's a proper or standard, clean way to connect two widgets between two windows, if widgets are private to each other?

      Thank you.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @pachisuro4096 said in How properly connect two widgets between two windows:

      I want trigger some slot of MyLabel by clicking buttons in SettingDialog.

      There are many things to say and many possibilities for your question. But I pick this out. Why do you want to trigger widget slots from some other dialog anyway? If this is such an issue. think about exporting the required functionality as a public method of its own.

      I will also just comment that inspecting Qt source code there are indeed examples where they spell out "redirecting" each signal of an object into another signal.

      If widgets are so "private" to each other I am "surprised" external objects want to access them. The idea of private is that external things just don't need to do that. Else maybe they (or rather accessors) need exposing.

      One last: depending on your requirements, you might be interested in QSignalMapper Class as an approach to reducing the number of distinct signals to deal with.

      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