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. Object from QToolbar in a QWidget

Object from QToolbar in a QWidget

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

    Hello, I designed a class which inherit from QToolBar. At this Toolbar there is a Button.
    Now I add this Toolbar to a QWidget, but if I click on the Button at the Toolbar nothing happens. Why is the Signal not send to the Toolbar?

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

      Hi, what signal do you expect it to send ?
      Did you connect button and toolbar ?
      Normally you would use QActions and pressing button would activate the action.

      M 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi, what signal do you expect it to send ?
        Did you connect button and toolbar ?
        Normally you would use QActions and pressing button would activate the action.

        M Offline
        M Offline
        Michelle02283
        wrote on last edited by
        #3

        @mrjj in the class which inherit from QToolBar is the Button "home". I wrote this: connect(home, SIGNAL(released(void)), this, SLOT(clickHome(void)));
        If I click on the Button in my Widget nothing happens.

        mrjjM 1 Reply Last reply
        0
        • M Michelle02283

          @mrjj in the class which inherit from QToolBar is the Button "home". I wrote this: connect(home, SIGNAL(released(void)), this, SLOT(clickHome(void)));
          If I click on the Button in my Widget nothing happens.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Michelle02283
          did you check that connect returns true ?
          To check connection can be made.
          maybe remove the void and just have released() and clickHome()

          M 1 Reply Last reply
          0
          • mrjjM mrjj

            @Michelle02283
            did you check that connect returns true ?
            To check connection can be made.
            maybe remove the void and just have released() and clickHome()

            M Offline
            M Offline
            Michelle02283
            wrote on last edited by
            #5

            @mrjj I tried with a QDebug if something happens, but nothing happens.

            mrjjM 1 Reply Last reply
            0
            • M Michelle02283

              @mrjj I tried with a QDebug if something happens, but nothing happens.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              @Michelle02283
              did you try
              qDebug() << "can conn:" << connect(home, SIGNAL(released()), this, SLOT(clickHome()));
              and see it says true ?

              Also do you have Q_OBJECT
              in your toolbar subclass ?

              M 1 Reply Last reply
              0
              • mrjjM mrjj

                @Michelle02283
                did you try
                qDebug() << "can conn:" << connect(home, SIGNAL(released()), this, SLOT(clickHome()));
                and see it says true ?

                Also do you have Q_OBJECT
                in your toolbar subclass ?

                M Offline
                M Offline
                Michelle02283
                wrote on last edited by
                #7

                @mrjj
                No, it says nothing.

                No I have no Q_OBJECT in my subclass. Why do I need it? I tried to add it, but I got an error.

                mrjjM 1 Reply Last reply
                0
                • M Michelle02283

                  @mrjj
                  No, it says nothing.

                  No I have no Q_OBJECT in my subclass. Why do I need it? I tried to add it, but I got an error.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Michelle02283
                  if it says nothing, then the connect is NOT executed ??

                  Yes, you need Q_OBJECT in your class
                  like
                  class HeightMap : public QWidget {
                  Q_OBJECT
                  ..

                  its good idea to delete all in build folder so u are sure its all rebuild after adding this macro.

                  M 1 Reply Last reply
                  2
                  • mrjjM mrjj

                    @Michelle02283
                    if it says nothing, then the connect is NOT executed ??

                    Yes, you need Q_OBJECT in your class
                    like
                    class HeightMap : public QWidget {
                    Q_OBJECT
                    ..

                    its good idea to delete all in build folder so u are sure its all rebuild after adding this macro.

                    M Offline
                    M Offline
                    Michelle02283
                    wrote on last edited by
                    #9

                    @mrjj the Q_OBJECT was the problem. I added it and now it works.
                    Thanks.

                    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