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. [SOLVED] Error to declare signal
Forum Update on Monday, May 27th 2025

[SOLVED] Error to declare signal

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 852 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.
  • G Offline
    G Offline
    guidupas
    wrote on 14 Feb 2014, 11:51 last edited by
    #1

    Hello All!

    I am trying to declare a signal as the code below shows:
    @
    //bancodados.h
    #ifndef BANCODADOS_H
    #define BANCODADOS_H

    #include <QObject>

    class bancoDados : public QObject
    {
    Q_OBJECT

    public:
    explicit bancoDados(QObject *parent = 0);

    signals:
    void conectar();

    public slots:

    };
    @
    @
    //bancodados.cpp
    #include "bancodados.h"

    #include <QSqlDatabase>

    bancoDados::bancoDados(QObject *parent) :
    QObject(parent)
    {

    }
    void bancoDados::conectar()
    {
    bool retorno = true;

    emit retorno;
    

    }
    @

    Well, when I run this code it show the error:
    @:-1: error: 1 duplicate symbol for architecture x86_64@

    But, if I change "void conectar();" from signals to public, it runs, but I need to it stays as a signal

    Can anyone help me?

    Thanks a lot.

    Att.
    Guilherme Cortada Dupas

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 14 Feb 2014, 12:03 last edited by
      #2

      Hi,

      signals don't have an implementation and you can't emit a variable.

      See the "Signals And Slots":http://qt-project.org/doc/qt-5/signalsandslots.html documention for more information

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • G Offline
        G Offline
        guidupas
        wrote on 14 Feb 2014, 14:26 last edited by
        #3

        Thaks a lot

        Att.
        Guilherme Cortada Dupas

        1 Reply Last reply
        0

        1/3

        14 Feb 2014, 11:51

        • Login

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