Dont see new signal on outside class

  • Hi,
    I reimpement QTextEdit:

    #ifndef MYTEXTEDIT_H
    #define MYTEXTEDIT_H

    #include <QtGui>
    #include <QtCore>

    class MyTextEdit : public QTextEdit
    explicit MyTextEdit(QWidget *parent);

    bool isEdited;

    void signalMouseDoubleClickEvent(QMouseEvent *e);

    public slots:

    void mouseDoubleClickEvent(QMouseEvent *e);

    #endif // MYTEXTEDIT_H

    #include "mytextedit.h"

    MyTextEdit::MyTextEdit(QWidget *parent)
    setParent( parent );
    isEdited = false;


    void MyTextEdit::mouseDoubleClickEvent(QMouseEvent *e)
    if( !anchorAt( e->pos() ).isEmpty() )
    emit signalMouseDoubleClickEvent(e);

    now if i declar new verbal MyTextEdit type then no have signal i dont know why. Is somting like public and prtected signal ???

    MyTextEdit *TextEdit;
    TextEdit = new MyTextEdit(this);

    connect(TextEdit, SIGNAL(),


  • Your post breaks with the interesting part. How do you connect your signal?
    Give the complete statement.
    Do you get an error message?

  • Signals are always protected from a technical point of view (only the class itself and its subclasses can emit them), and always public from a logical point of view (everyone can connect to a signal).

    The code you've posted works correctly. Make sure that you've included the header file mytextedit.h (no forward declaration) and that you've re-run qmake after adding the signal.

    In addition, you are missing a call to the base class constructor.
    MyTextEdit::MyTextEdit(QWidget *parent = 0) : QTextEdit(parent)
    isEdited = false;

Log in to reply