Connecting to Undeclared Slots
Hello,
I'm starting to get the hang of QT. I found an older tutorial that has really helped me but there are some differences between version 2.3 and 4.3 which need addressing. In version 2.3 (the one my tutorial was written for) you could easily connect slots that didn't already exist in the Designer and then define them later in code. In 4.3 how can you connect slots that aren't preprogrammed in the Designer?
Another related question: I have a MainWindow form with a menu. The menu has one field called Actions and the Actions menu has one action called: connect.
When connect is clicked I want to activate my connect socket code. Could someone possibly outline the .h file I'd need for this? I'm confused about the sub-classing involved.
Here's what I'm thinking:
Code:
#ifndef MCHAT_H
#include "ui_MChat.h"
Q_OBJECT
public:
private slots:
/* Somehow tell action_Connect() that it should call this slot
when activated() is signalling */
virtual void connect();
#endif MCHAT_H
Re: Connecting to Undeclared Slots
First of all I suggest you don't use "connect" as the name for your method, because it is easy to have a name clash with QObject::connect().
Here is a link that will describe you how to use Designer created components in your applications: http://doc.trolltech.com/latest/desi...component.html
Re: Connecting to Undeclared Slots
Thanks, but I don't see where it talks about connecting slots via the designer in that tutorial.
Re: Connecting to Undeclared Slots
You can't connect slots via Designer in Qt4. The reference tells you how to declare and use Designer created components in your applications (including how to add slots).
Re: Connecting to Undeclared Slots
Ah, okay thanks. (Too bad though...)
Re: Connecting to Undeclared Slots
Quote:
Originally Posted by
Dumbledore
(Too bad though...)
Not really... You'd have to declare and implement the slot in the subclass anyway. And you can use the auto-connect feature to avoid the need of having to write the connect statement. So in reality this is less work and not more.