Qt-jambi-interest Archive, February 2007
Very basic question about creating slots in Eclipse
Message 1 in thread
From within Eclipse when editing a Qt UI file, what is the procedure for
creating a new slot. I can see how to use existing predefined ones, but
not new ones.
I looked in the Qt Designer docs and it does not say (it says you can have
your own but not how to create them), and all the tutorials that google finds
either show connecting to existing slots or are based on very old versions
of designer.
I realise that this is probably a designer question rather than a jambi
question, but if there are any differences with Eclipse it is that answer
that I am really after.
Thank you.
David
Message 2 in thread
Hi, David.
David Goodenough wrote:
>From within Eclipse when editing a Qt UI file, what is the procedure for
>creating a new slot. I can see how to use existing predefined ones, but
>not new ones.
>
>I looked in the Qt Designer docs and it does not say (it says you can have
>your own but not how to create them), and all the tutorials that google finds
>either show connecting to existing slots or are based on very old versions
>of designer.
>
>I realise that this is probably a designer question rather than a jambi
>question, but if there are any differences with Eclipse it is that answer
>that I am really after.
>
>
There's no way to add slots in neither Qt Designer nor its Eclipse
integration. Slots will have to be added manually to the class by code
(in Qt Jambi, any method is a slot unless otherwise specified.) In the
currently available version, this unfortunately means that you cannot
use Designer to connect your custom signals and slots, because it has no
way of reading your class definitions.
In the upcoming beta release, however, there has been a lot of focus on
providing a Qt Designer (both as a standalone app and an integration in
Eclipse) which is specially tailored for use with Qt Jambi. One of the
new features is the ability to import class files as custom widgets in
the widget box, and drag and drop them into your form. Signals, slots
and properties declared for this class will then be available through
the regular Designer interface.
-- Eskil
Message 3 in thread
On Tuesday 06 February 2007 10:36, Eskil A. Blomfeldt wrote:
> Hi, David.
>
> David Goodenough wrote:
> >From within Eclipse when editing a Qt UI file, what is the procedure for
> >creating a new slot. I can see how to use existing predefined ones, but
> >not new ones.
> >
> >I looked in the Qt Designer docs and it does not say (it says you can have
> >your own but not how to create them), and all the tutorials that google
> > finds either show connecting to existing slots or are based on very old
> > versions of designer.
> >
> >I realise that this is probably a designer question rather than a jambi
> >question, but if there are any differences with Eclipse it is that answer
> >that I am really after.
>
> There's no way to add slots in neither Qt Designer nor its Eclipse
> integration. Slots will have to be added manually to the class by code
> (in Qt Jambi, any method is a slot unless otherwise specified.) In the
> currently available version, this unfortunately means that you cannot
> use Designer to connect your custom signals and slots, because it has no
> way of reading your class definitions.
>
> In the upcoming beta release, however, there has been a lot of focus on
> providing a Qt Designer (both as a standalone app and an integration in
> Eclipse) which is specially tailored for use with Qt Jambi. One of the
> new features is the ability to import class files as custom widgets in
> the widget box, and drag and drop them into your form. Signals, slots
> and properties declared for this class will then be available through
> the regular Designer interface.
>
> -- Eskil
Well that would explain why I could not find it.
Many moons ago I tried to use the version of juic that was created as
part of the kdebindings project.
In that setup the Ui file was generated in the normal way, and as far
as I can remember you created slots in the normal way, and this created
a Java class that you subclassed with the application function. Thus
separating the UI and the business logic. Slots where creates as
abstract methods which you had to provide in the subclass for it to
compile cleanly.
Do I gather that with QT Jambi the intended flow is to create the Ui
first and then modify the code to include the business logic. If so
I think this is a retrograde step and should be reconsidered.
David
Message 4 in thread
Hi, David.
David Goodenough wrote:
>Many moons ago I tried to use the version of juic that was created as
>part of the kdebindings project.
>
>In that setup the Ui file was generated in the normal way, and as far
>as I can remember you created slots in the normal way, and this created
>a Java class that you subclassed with the application function. Thus
>separating the UI and the business logic. Slots where creates as
>abstract methods which you had to provide in the subclass for it to
>compile cleanly.
>
>Do I gather that with QT Jambi the intended flow is to create the Ui
>first and then modify the code to include the business logic. If so
>I think this is a retrograde step and should be reconsidered.
>
>
The Java-bindings that were part of KDE were based on Qt 3. The
possibility of adding custom slots to a class in Designer was
intentionally removed for Qt 4, as feedback indicated that people
considered it a troublesome and confusing mix of different types of
logic. There are people who salute this change and there are people who
miss the feature when they convert to Qt 4 (or Qt Jambi), but we believe
that once the new pattern becomes familiar, the benefits of the
"cleaner" separation of the user interface and application code becomes
clear.
Note, however, that it is not intended that you modify the code
generated by juic. In fact, any modifications you make to it will be
overwritten the next time you run juic on your .ui file. In Qt 4 and Qt
Jambi, Designer is principally a tool for efficiently designing the GUI
of your application. The code generated by Juic will be a plain class
with a method setupUi() which you can call to establish the user
interface on a top level widget of your choice (the code of which is
otherwise completely independent of the generated code.)
The pattern we recommend is to make a main class that initializes an
object of the generated class and calls the setupUi() method from its
constructor, passing the this-reference as the argument.
Here's a code snippet as example. Lets say the main class is called
FooBar, and the generated class, which is made in Designer as a main
window, is called Ui_FooBar.
---
class FooBar extends QMainWindow {
private Ui_FooBar ui = new Ui_FooBar();
public FooBar() {
ui.setupUi(this);
}
}
--
[ signature omitted ]