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. Possible to move event slots?
Forum Updated to NodeBB v4.3 + New Features

Possible to move event slots?

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 1.6k 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.
  • S Offline
    S Offline
    sting
    wrote on last edited by
    #1

    I have a couple of QTableWidget instances in a QGroubBox and the tables have a data dependency. When an element is selected in one table data associated with the selected element is written to the second box.

    When I added the slot, the slot entry and the method were added to mainwindow. First, main window at least two levels away from the group box, and it seems reasonable that the group box should be responsible for its operation.

    Is it possible to move the slot from the mainwindow to the groupbox. If all of the slots are managed by mainwindow, the mainwindow will become a very large entity, and very confusing. I know form mainwindow I can send a message to the groupbox to get the work done, it just seems better if I can move it.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Sure you can, just create a custom widget that will have these slots and contain all the needed "sub widgets" , nothing wrong with that at all. You can see it done in Qt's examples and demos

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sting
        wrote on last edited by
        #3

        I just tried to move the slot and the method from mainwindow to the subclasses QGroupBox that has slots and make complained that it needed the method in mainwindow. I will try it again. Thank you.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sting
          wrote on last edited by
          #4

          I just copied the slot and the method, it ran fine but I got a runtime message:

          QMetaObject::connectSlotByName: No matching signal for on_scheduleTable_clicked(QModelIndex)

          Is it because the QGroupBox doesn't have an instance variable for its children?

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Did you made a separate widget with designer for each group box ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sting
              wrote on last edited by
              #6

              I made a separate subclass of QGroupBox for each group box I use. I promotted each groupbox in Qt Creator to the respective subclass. I think I need to use connect to make it work, which seems to have been done automatically for me in the mainwindow scenario.

              Sorry, but I have only been able to use Qt for a few days and I am still in the learning phase. I probably should wait longer before I post, but I'm just not sure of the language to know what to search for.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Then just take the documentation and search for Designer, you'll have several guides that will help you

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                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