Russian Qt Forum
Сентябрь 30, 2024, 08:14 *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

Войти
 
  Начало   Форум  WIKI (Вики)FAQ Помощь Поиск Войти Регистрация  

Страниц: [1]   Вниз
  Печать  
Автор Тема: Помогите с наследованием сигнала  (Прочитано 4235 раз)
kvrus
Гость
« : Август 13, 2012, 09:52 »

Есть базовый класс (наследник QTabWidget) который содержит в себе обработчики события драг и дропа, и содержит
сигнал, который испускается когда драг и дроп произошел над экземпляром этого класса.
Дальше есть несколько классов наследников, которые хотят заполучить эту возможность отлавливать драг и дроп
и испускать сигнал. После запуска приложения выводится сообщение QObject::connect: No such signal B::change(int, int)
такая запись на все экземпляры, и еще один раз пишет тоже самое но для родительского класса.
Я полагал, что сигналы - это приват область и они должны наследоваться.
В чем тогда прикол?
Записан
_OLEGator_
Гость
« Ответ #1 : Август 13, 2012, 09:54 »

Код показывай
Записан
kvrus
Гость
« Ответ #2 : Август 13, 2012, 10:04 »


Это родитель:
class Plotter : public QTabWidget{
    Q_OBJECT
    QImage  m_plotterIcon;
    QString m_name;
public:
    explicit Plotter(QWidget *parent = 0);
    QImage getIcon() const{
        return m_plotterIcon;
    }
    int plotterID;
    QString getName() const{
        return m_name;
    }
signals:
    void changePlot(int currentPlotter, int nextPlotter);
protected:
    void dragEnterEvent(QDragEnterEvent *event);
    void dragMoveEvent(QDragMoveEvent *event);
    void dropEvent(QDropEvent *event);
};
от него наследуются все перечисленные ниже классы вот по такому принципу:
class evmplot : public QTabWidget

Это коннекты в bg_w.cpp
    connect(timeplotter, SIGNAL(changePlot(int,int)),this, SLOT(setCurrentIndex(int,int)));
    connect(freqplotter, SIGNAL(change_plot(int,int)),this, SLOT(setCurrentIndex(int,int)));
    connect(constellationplotter, SIGNAL(change_plot(int,int)),this, SLOT(setCurrentIndex(int,int)));
    connect(vectorplotter, SIGNAL(change_plot(int,int)),this, SLOT(setCurrentIndex(int,int)));
    connect(Ieyeplotter, SIGNAL(change_plot(int,int)),this, SLOT(setCurrentIndex(int,int)));
    connect(Qeyeplotter, SIGNAL(change_plot(int,int)),this, SLOT(setCurrentIndex(int,int)));
    connect(spectrogramplotter, SIGNAL(change_plot(int,int)),this, SLOT(setCurrentIndex(int,int)));
    connect(symtableplotter,SIGNAL(change_plot(int,int)),this, SLOT(setCurrentIndex(int,int)));
    connect(evmplotter,SIGNAL(change_plot(int,int)),this, SLOT(setCurrentIndex(int,int)));
Это в консоли приложения после запуска:
Object::connect: No such signal TimePlotter::change_plot(int,int) in ..\VSA\bg_w.cpp:26
Object::connect: No such signal FreqPlotter::change_plot(int,int) in ..\VSA\bg_w.cpp:27
Object::connect: No such signal ConstellationPlotter::change_plot(int,int) in ..\VSA\bg_w.cpp:28
Object::connect: No such signal VectorPlotter::change_plot(int,int) in ..\VSA\bg_w.cpp:29
Object::connect: No such signal EyePlotter::change_plot(int,int) in ..\VSA\bg_w.cpp:30
Object::connect: No such signal EyePlotter::change_plot(int,int) in ..\VSA\bg_w.cpp:31
Object::connect: No such signal SpectrogramPlotter::change_plot(int,int) in ..\VSA\bg_w.cpp:32
Object::connect: No such signal SymTablePlotter::change_plot(int,int) in ..\VSA\bg_w.cpp:33
Object::connect: No such signal Plotter::change_plot(int,int) in ..\VSA\bg_w.cpp:34
D:\ASP\prg2012\VSA-build-desktop\debug\VSA.exe завершился с кодом 0

Записан
kvrus
Гость
« Ответ #3 : Август 13, 2012, 10:05 »

Ой)))) напутал чуток)))
Записан
kvrus
Гость
« Ответ #4 : Август 13, 2012, 10:08 »




Просмотр профиля Email Личное сообщение (Online)
   
   
Re: Помогите с наследованием сигнала
« Ответ #2 : Сегодня в 10:04 »
   ПроцитироватьЦитировать Редактировать сообщениеИзменить Удалить сообщениеУдалить

Это родитель:
class Plotter : public QTabWidget{
    Q_OBJECT
    QImage  m_plotterIcon;
    QString m_name;
public:
    explicit Plotter(QWidget *parent = 0);
    QImage getIcon() const{
        return m_plotterIcon;
    }
    int plotterID;
    QString getName() const{
        return m_name;
    }
signals:
    void changePlot(int currentPlotter, int nextPlotter);
protected:
    void dragEnterEvent(QDragEnterEvent *event);
    void dragMoveEvent(QDragMoveEvent *event);
    void dropEvent(QDropEvent *event);
};
от него наследуются все перечисленные ниже классы вот по такому принципу:
class EvmPlotter : public Plotter - Вот это наследник

Это коннекты в bg_w.cpp
    connect(timeplotter, SIGNAL(changePlot(int,int)),this, SLOT(setCurrentIndex(int,int)));
    connect(freqplotter, SIGNAL(change_plot(int,int)),this, SLOT(setCurrentIndex(int,int)));
    connect(constellationplotter, SIGNAL(change_plot(int,int)),this, SLOT(setCurrentIndex(int,int)));
    connect(vectorplotter, SIGNAL(change_plot(int,int)),this, SLOT(setCurrentIndex(int,int)));
    connect(Ieyeplotter, SIGNAL(change_plot(int,int)),this, SLOT(setCurrentIndex(int,int)));
    connect(Qeyeplotter, SIGNAL(change_plot(int,int)),this, SLOT(setCurrentIndex(int,int)));
    connect(spectrogramplotter, SIGNAL(change_plot(int,int)),this, SLOT(setCurrentIndex(int,int)));
    connect(symtableplotter,SIGNAL(change_plot(int,int)),this, SLOT(setCurrentIndex(int,int)));
    connect(evmplotter,SIGNAL(change_plot(int,int)),this, SLOT(setCurrentIndex(int,int)));
Это в консоли приложения после запуска:
Object::connect: No such signal TimePlotter::change_plot(int,int) in ..\VSA\bg_w.cpp:26
Object::connect: No such signal FreqPlotter::change_plot(int,int) in ..\VSA\bg_w.cpp:27
Object::connect: No such signal ConstellationPlotter::change_plot(int,int) in ..\VSA\bg_w.cpp:28
Object::connect: No such signal VectorPlotter::change_plot(int,int) in ..\VSA\bg_w.cpp:29
Object::connect: No such signal EyePlotter::change_plot(int,int) in ..\VSA\bg_w.cpp:30
Object::connect: No such signal EyePlotter::change_plot(int,int) in ..\VSA\bg_w.cpp:31
Object::connect: No such signal SpectrogramPlotter::change_plot(int,int) in ..\VSA\bg_w.cpp:32
Object::connect: No such signal SymTablePlotter::change_plot(int,int) in ..\VSA\bg_w.cpp:33
Object::connect: No such signal Plotter::change_plot(int,int) in ..\VSA\bg_w.cpp:34
D:\ASP\prg2012\VSA-build-desktop\debug\VSA.exe завершился с кодом 0
Записан
_OLEGator_
Гость
« Ответ #5 : Август 13, 2012, 10:09 »

Ты издеваешься блин?!
У тебя сигнатура сигнала changePlot, а ты используешь неизвестный сигнал change_plot
Записан
kvrus
Гость
« Ответ #6 : Август 13, 2012, 10:11 »

елы палы!
Спасибо большое. Сижу все привожу к единому стилю в проекте вот и получилась запарка
Записан
_OLEGator_
Гость
« Ответ #7 : Август 13, 2012, 10:12 »

Рефакторинг? Не, не слышал.
Есть средства для рефакторинга, а ты все руками походу делаешь.
Записан
kvrus
Гость
« Ответ #8 : Август 13, 2012, 10:14 »

сейчас покурю по автоматизированным средствам. Еще раз спасибо.
Записан
_OLEGator_
Гость
« Ответ #9 : Август 13, 2012, 10:16 »

Если ты используешь Qt Creator, то помоему там есть встроенные средства для рефакторинга.
Записан
Serr500
Гость
« Ответ #10 : Август 13, 2012, 16:46 »

Да там точно есть. Правой крысой по объекту и в меню "Рефакторинг".
Записан
Страниц: [1]   Вверх
  Печать  
 
Перейти в:  


Страница сгенерирована за 0.049 секунд. Запросов: 21.