[Kde-games-devel] Problem with signals and slots

ahmmahfuz rubel 65mahfuz90 at gmail.com
Sun Jul 12 05:29:33 CEST 2009


Thanks. I already managed this to work perfectly.

On Sun, Jul 12, 2009 at 10:16 AM, Zeng Huan <zh.issac at gmail.com> wrote:

> Then put setupWidgets() before setupGame() and move the connection inside
> setupGame() and before your emit.
>
>     connect(this, SIGNAL( signalLoadTheme()), m_gameTheme, SLOT(
> slotLoadTheme() ));
>     emit signalLoadTheme();
>
>
>
> On Sun, Jul 12, 2009 at 11:06 AM, ahmmahfuz rubel <65mahfuz90 at gmail.com>wrote:
>
>> Actually, there was a 2 way problem. I tried both and both failed.
>>
>> Because if setupWidgets() is called first then m_gameTheme is invalid and
>> if setupGame() is first then emit signalLoadTheme(); is invalid as
>> connection is not made yet. So, though not crash in this case, the slot will
>> not be called.
>>
>> Thanks for help
>> Mahfuz
>>
>>
>> On Sun, Jul 12, 2009 at 9:37 AM, Zeng Huan <zh.issac at gmail.com> wrote:
>>
>>> Hi,
>>> Sorry for my typo.
>>> you did not create your m_gameTheme before you make connection to it,
>>> just put setupGame() before setupWidgets()* can fix your problem. line23:24
>>> in MainWindow.cpp
>>>
>>>
>>> On Sun, Jul 12, 2009 at 10:35 AM, Zeng Huan <zh.issac at gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> you did not create your m_gameTheme before you make connection to it,
>>>> just put setupGame() before m_gameTheme can fix your problem. line23:24 in
>>>> MainWindow.cpp
>>>>
>>>> On Sun, Jul 12, 2009 at 10:17 AM, ahmmahfuz rubel <65mahfuz90 at gmail.com
>>>> > wrote:
>>>>
>>>>> I am having some problem when I tried to connect signals and slots of
>>>>> different classes. It was not a problem when I connected signals and slots
>>>>> within the same class(I even don't included the moc file!).
>>>>>
>>>>> This is what I have done to connect two different classes:
>>>>>
>>>>> I have a signal declared in MainWindow(inheritx kxmlGuiWindow) class
>>>>> named signalLoadTheme()
>>>>> and a slot in ThemeManager class(inherits QSvgRenderer) named
>>>>> slotLoadTheme().
>>>>>
>>>>> I created a instance of ThemeManager in MainWindow name m_gameTheme(
>>>>> ThemeManager* m_Theme)
>>>>> and connected them in MainWindow using:
>>>>>
>>>>> *connect(this, SIGNAL( signalLoadTheme()), m_gameTheme, SLOT(
>>>>> slotLoadTheme() ));*
>>>>>
>>>>>
>>>>> I used Q_OBJECT in both of the classes at first (tried also including
>>>>> moc files).
>>>>>
>>>>>
>>>>> But, this is not working, my program is crashing.
>>>>>
>>>>> *mahfuz at mahfuz-desktop:/usr/local/bin$ ./TestSignalSlot
>>>>> KCrash: Application 'TestSignalSlot' crashing...
>>>>> sock_file=/home/mahfuz/.kde/socket-mahfuz-desktop/kdeinit4__0
>>>>> Warning: connect() failed: : No such file or directory
>>>>> KCrash cannot reach kdeinit, launching directly.
>>>>>
>>>>> *
>>>>> The necessary parts of my program is attached here(Not full, it is
>>>>> big).
>>>>>
>>>>> Please Help. Also, let me know, when and why including the moc file is
>>>>> must.
>>>>>
>>>>> Thanks in advance.
>>>>> Mahfuz
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> kde-games-devel mailing list
>>>>> kde-games-devel at kde.org
>>>>> https://mail.kde.org/mailman/listinfo/kde-games-devel
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Cheers,
>>>> Zeng Huan
>>>>
>>>
>>>
>>>
>>> --
>>> Cheers,
>>> Zeng Huan
>>>
>>> _______________________________________________
>>> kde-games-devel mailing list
>>> kde-games-devel at kde.org
>>> https://mail.kde.org/mailman/listinfo/kde-games-devel
>>>
>>>
>>
>> _______________________________________________
>> kde-games-devel mailing list
>> kde-games-devel at kde.org
>> https://mail.kde.org/mailman/listinfo/kde-games-devel
>>
>>
>
>
> --
> Cheers,
> Zeng Huan
>
> _______________________________________________
> kde-games-devel mailing list
> kde-games-devel at kde.org
> https://mail.kde.org/mailman/listinfo/kde-games-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/kde-games-devel/attachments/20090712/0259167c/attachment.htm 


More information about the kde-games-devel mailing list