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. Signals & Slots problems
QtWS25 Last Chance

Signals & Slots problems

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 2.0k 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.
  • C Offline
    C Offline
    cejohnsonsr
    wrote on last edited by
    #1

    I'm using the latest SDK on Fedora 13 64bit. I've been trying to follow the tutorials & examples provided to reaquaint myself with C++ & Qt. I'm having a problem trying to use the Signals & Slots in a small practice app. The slot I wrote to respond to a button click isn't listed in the Signals & Slots editor. I tried to connect as shown in the docs, but the compiler throws about a thousand errors. The docs don't say or show exactly where the connection should be (i.e. which file & where in the file). I've stomped over it so much that I have myself thoroughly confused. It doesn't help that I haven't tried to write anything in almost 8 years. Would anyone be willing to hold my hand for a bit & walk me through how to get this done? I know it can't be THAT hard. Thanks in advance for any help.

    Ed

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #2

      You can simply add connect() to your form constructor. Something like that:

      @
      MyForm::MyForm(QWidget *parent) : QWidget(parent)
      {
      //...
      connect(ui->myButton, SIGNAL(clicked()), this, SLOT(buttonClicked()));
      //...
      }
      @

      or create slot named as on_myButton_clicked() in form, containing myButton (replace it with your name for needed signal emitter).

      1 Reply Last reply
      0
      • E Offline
        E Offline
        evanxg852000
        wrote on last edited by
        #3

        two things I jsut want to remind u .
        Make sure you write Q_OBJECT macro in you header file

        and declare your slot in the slot section of the header :
        @
        class myForm ..
        {
        Q_OBJECT

        private slots:
        void butonclick();

        }@

        but when subclassing from a ui file , the last method of the abov reply is more conveniant as it auto-connect directly

        Evan-XG

        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