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 to connect signals from within the GUI/form creator to code.
QtWS25 Last Chance

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

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

    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
    0
    • J Offline
      J Offline
      javajames
      wrote on last edited by
      #2

      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
      0
      • T Offline
        T Offline
        tchoninho
        wrote on last edited by
        #3

        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
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved