views:

1080

answers:

2

We're about to commit to Qt and C++ (sigh) to do some cross-platform development. The latest version of Qt 4.5 seems very nice as does the QT Creator IDE, which although simple compared to other IDEs, is a good way to get started.

I'm trying to understand how to do drag and drop into QT widgets from the "outside" world. As far as I can tell from the documentation, you're supposed to subclass a widget that you want to have respond to drop events and override some methods (the dragEnterEvent and dropEvent member functions) for that widget.

But if I use the Qt Creator tool, I don't seem to have any access to the classes of the widgets that I have created using the GUI form builder and so I can't subclass them.

WHat's the secret?

Thanks in advance, D

A: 

I've never used QT creator environment, but I assume it spits out code afterward. Can you edit the code it spits out?

If you subclass the classes in a separate file, it shouldn't get overwritten when you rebuild your app with QT creator environment.

I suppose this is really a question for the QT creator forum though, sounds like a problem in THEIR user interface.

asperous.us
That would be too easy (grin). It saves the GUI layout in an XML representation. And since there are classes that can load/instantiate that representation at runtime, it's clear that you run stuff without ever seeing C++ code.While they may very well have a tool that lets you get at that C++ code, it's clear to me that if you were to modify that, then you lose the benefit of using the GUI tool. So I'm HOPING there's something else to handle this in a "supported" manner.
David
+4  A: 

Someone on my team figured it out ---- turns out there is an option to "Promote" a widget, meaning you can subclass it to something else and then override the needed methods with no pain.

Seems to me it would have been more obvious if it said "Subclass widget..." rather than "Promote" but that's OK.

This QT Creator is a very nice piece of work.

David