10741

Implementing drag and drop with QT 4.5 using QT Creator environment

Question:

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

Answer1:

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.

Answer2:

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.

Recommend

  • Is it OK to write code after [super dealloc]?
  • Is it good practice to put Edge Side Includes into my templates?
  • JQuery UI selectable plugin - Multiple mouse drag selection and unselect option
  • Problem with sockets in C#
  • Change color of row programmatically in WatchKit
  • Can't CTRL+Drag NSButton to custom NSView header
  • k-ary Trees in Java
  • Condor job using DAG with some jobs needing to run the same host
  • jquery draggable stop event
  • Starting Android AVD crashes with java.awt.HeadlessException
  • Index.php as custom error page
  • Client side validation mvc dropdown
  • Pre-populated SQLite Database not reading properly in Android Studio
  • Watson Conversation - Why is the ANYTHING ELSE node not chosen
  • Deploying a CodeRush plugin from the Community Site
  • pickle.PicklingError: args[0] from __newobj__ args has the wrong class with hadoop python
  • Using same constraints in multiple classes
  • why calling cd shell command through system() or execvp() from a child process won't work?
  • LiveData is abstract android
  • extjs4 catching the scroll event on panel
  • Two Tables Serving as one Model in Rails
  • Using $compile in a directive triggers AngularJS infinite digest error
  • there is no graph with tensorboard
  • How to override value that appears in a dropdown in the rails_admin gem
  • JqueryMobile Popup menu is not working
  • Execute scripts AJAX returns
  • Android - Material Design - NavigationView - How to put vertical scroll?
  • Caching attributes in superclass
  • Word Open XML Mail Merge
  • How do I change content of ComboFieldEditor?
  • Java applet as stand-alone Windows application?
  • output of program is not same as passed argument
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Where to put my custom functions in Wordpress?
  • Statically linking a C++ library to a C# process using CLI or any other way
  • Jquery - Jquery Wysiwyg return html as a string
  • Why winpcap requires both .lib and .dll to run?
  • Cannot Parse HTML Data Using Android / JSOUP
  • SQL merge duplicate rows and join values that are different
  • Reading document lines to the user (python)