Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. New to Qt having fun but...
Qt 6.12 LTS is out! See what's new in the release blog

New to Qt having fun but...

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 2.4k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Trying to wrap my head around the whole signal slot thing....

    Qt Creator 2.1.0 - Qt 4.7.1 base
    OpenSuSe GNome
    gcc 4.5.1 Posix Thread Model

    I get the signal slot editor in designer but am sort of stuck on just coding a method, working on the paradigm.

    For Example ( Please don't hate me )...

    In Delphi ( The RAD tool I am most familiar with ) you would take the value of a text box and set a labels value based on a button click ( Really being brief here ) like so...

    button.Click(sender tObject);
    begin
    label1.caption := textbox1.text ;
    end;

    Now Qlabel has a text property as does a QlineEdit and a QpushButton has a clicked() signal which is synonymous to an event, I think..

    So would I have to define a custom signal to override the clicked() event to say copy the text from the edit control to the label?

    I am not looking to be spoon fed, just trying to understand the paradigm s I can't seem to find any simple examples of doing things like that.

    Thanks so very much in advance....

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      Did you read the "Signals and Slots":http://doc.trolltech.com/latest/signalsandslots.html introduction? It seems to answer your question more or less.

      Signals are just that: signals. There is nothing that dictates if and how you should react to signals. Slots however are the functional part. You write a function that performs some action, say copy a text from one object (line edit) to another (label). If you define that as being a slot, you get the added option of connecting a signal to it. When you have made the connection, the slot will be executed once an other object (button) fires a signal (clicked()).

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        And remember that a slot is a normal C++ function (member function). Therefore you can perform any action in your slot. For your example, it will give :

        @
        void MyClass::onMyButtonClicked()
        {
        myLabel->setText(myLineEdit->text());
        }
        @

        And btw, welcome and have fun with Qt :)

        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
        • Unsolved