Подтвердить что ты не робот

QtRuby emit не работает

Платформа:

Дарвин * - * s-MacBook-Pro.local 11.4.2 Ядро Дарвина Версия 11.4.2: Чт Авг 23 16:25:48 PDT 2012; root: xnu-1699.32.7 ~ 1/RELEASE_X86_64 x86_64

Ruby:

ruby ​​2.0.0p0 (исправление 2013-02-24 версия 39474) [x86_64-darwin11.4.2] (устанавливается rvm)

Qt:

qt: стабильный 4.8.4 (в бутылках), HEAD

Код

require 'Qt'

class Foo < Qt::Object

    signals :my_signal #also tried 'my_signal()'
    slots 'my_slot()'

    def initialize(parent = nil)
        super(parent)

        puts "connecting signal and slot"
        Qt::Object.connect(self, SIGNAL('my_signal()'), self, SLOT('my_slot()'))
        # also tried => connect(self, SIGNAL('my_signal()'), self, SLOT('my_slot()'))

    end

    def emit_my_signal
        puts "sending signal"
        emit my_signal
    end

    def my_slot
        puts "received message from signal"
    end
end


o = Foo.new
o.emit_my_signal

Выход

connecting signal and slot
sending signal

Вывод с Qt.debug_level = Qt:: DebugLevel:: Высокий

Munged method names:
        QObject$
        QObject?
        QObject#
candidate list:
    QObject* QObject::QObject(QObject*)  (smoke: 0 index: 3804)
matching => smoke: 0 index: 3804
        QObject* (u) score: 2
        match => smoke: 0 index: 3804 score: 2 chosen: 3804
setCurrentMethod(smokeList index: 0, meth index: 3804)
connecting signal and slot
Searching for QObject#connect
Munged method names:
        connect#$#$
candidate list:
    static bool QObject::connect(const QObject*, const char*, const QObject*, const char*)  (smoke: 0 index: 3850)
matching => smoke: 0 index: 3850
        const QObject* (QObject) score: 3
        const char* (s) score: 1
        const QObject* (QObject) score: 3
        const char* (s) score: 1
        match => smoke: 0 index: 3850 score: 8 chosen: 3850
setCurrentMethod(smokeList index: 0, meth index: 3850)
sending signal

Кажется, что emit ничего не делает. Я также попытался переустановить qt и qtbindings, но проблема все еще существует. А также я попробовал PyQt с сигналом и слотом на одной машине, он работает как шарм.

Есть ли у кого-нибудь идеи об этом? Является ли это ошибкой ruby ​​qtbindings или я просто что-то не так?

4b9b3361

Ответ 1

Код выглядит правильным. Проблема проявилась только в определенной комбинации рубиновых и qtbindings-версий, которые теперь устарели.

Ответ 2

Обычно необходимо запустить цикл событий Qt, прежде чем можно будет надежно доставить любые сигналы. Я не вижу этого в вашем коде. В частности, мне не хватает:

app = Qt::Application.new(ARGV)
app.exec