Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    How to connect signals from within the GUI/form creator to code.

    General and Desktop
    2
    3
    1149
    Loading More Posts
    • 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.
    • J
      javajames last edited by

      I've been experimenting with QT in the QTCreator tool kit, and I can't work out how to connect a button::clicked() signal to a custon written slot.

      I have my class DockWidget which I created using the "QT Designer form class" wizard. And I have a simple dock widget with a button on it. I then added a public slot for the click button signal (to DockWidget) (and wrote the function in the respective cpp file):

      @public slots:
      void onClickButton();@

      Then I go to the form layout designer and under "Signals and slots editor" I select the pushButton object as the sender, the clicked() signal and the DockWidget object as the reciever, however my slot isn't in drop down menu for slots.

      I'm definitely doing something wrong but at the moment I've been going by trial and error because I can't find any documentation on writing code along side using the form designer. Am I doing something very patently wrong? Could I have some documentation on connecting the objects I've created in the form designer to actual code?

      Thanks in advanced.

      1 Reply Last reply Reply Quote 0
      • J
        javajames last edited by

        Oh, that's what ui is for...

        @ui->setupUi(this);
        connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(on_pushButton_clicked()));@

        All of the objects from that form are available there. Stupid me.

        1 Reply Last reply Reply Quote 0
        • T
          tchoninho last edited by

          If you use prefix and suffix in your slots, e.g. "on_widgetName_clicked()". Qt will connect signals and slots automatically.

          Computer Scientist
          Belo Horizonte - Brasil
          C++ Development
          Qt Development

          1 Reply Last reply Reply Quote 0
          • First post
            Last post