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. Dont see new signal on outside class
Forum Updated to NodeBB v4.3 + New Features

Dont see new signal on outside class

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

    Hi,
    I reimpement QTextEdit:

    .h
    [code]
    #ifndef MYTEXTEDIT_H
    #define MYTEXTEDIT_H

    #include <QtGui>
    #include <QtCore>

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

    private:
    bool isEdited;

    signals:
    void signalMouseDoubleClickEvent(QMouseEvent *e);

    public slots:

    protected:
    void mouseDoubleClickEvent(QMouseEvent *e);
    };

    #endif // MYTEXTEDIT_H
    [/code]

    .cpp
    [code]
    #include "mytextedit.h"

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

    }

    void MyTextEdit::mouseDoubleClickEvent(QMouseEvent *e)
    {
    QTextEdit::mouseDoubleClickEvent(e);
    if( !anchorAt( e->pos() ).isEmpty() )
    emit signalMouseDoubleClickEvent(e);
    }
    [/code]

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

    main.cpp
    [code]
    MyTextEdit *TextEdit;
    TextEdit = new MyTextEdit(this);

    connect(TextEdit, SIGNAL(),

    [/code]

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

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

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lgeyer
        wrote on last edited by
        #3

        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;
        }
        @

        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