Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    How to make "Cusrom Widget" being able to drag-drop in?

    General and Desktop
    4
    7
    3991
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Y
      yaoyulian last edited by

      I want my "Cusrom Widget" to be a container, like "group box", "tool box", "tab widget". We can drag another control widget to these control widget. But my "Cusrom Widget" can't accept the drag-drop, i can't drag another control widget into my "Cusrom Widget" .
      How to make "Cusrom Widget" supports drag-drop?

      1 Reply Last reply Reply Quote 0
      • M
        maxvanceffer last edited by

        Did you mean Custom Widget ? Or describe what is “Cusrom Widget” !

        1 Reply Last reply Reply Quote 0
        • ?
          Guest last edited by

          there is a draggable iocns example that ships with Qt sdk, have you seen its code? that be what you seek?

          1 Reply Last reply Reply Quote 0
          • D
            danilocesar last edited by

            Is your cusrom widget "able to receive drops":http://doc.qt.nokia.com/4.7/qwidget.html#acceptDrops-prop?

            Maybe "this":http://doc.qt.nokia.com/4.7/dnd.html can help you as well.

            <a href="http://www.danilocesar.com">Danilo Cesar Lemes de Paula</a>
            Software Engineer

            1 Reply Last reply Reply Quote 0
            • Y
              yaoyulian last edited by

              I'm sorry for my English.
              There is an example "qt\examples\designer\customwidgetplugin".
              I mean this is “Custom Widget”
              In QtCreator, at left is control widget, in middle is work space, at right is property. The left is divided into Layouts, Spacers, Buttons, Containers, Input Widgets, Display Widgets ...
              I create a "Qt Custom Designer Widget" project. Build it. Then I can see my "Cusrom Widget" at the QtCreator's left side.
              I can drag my “Cusrom Widget” into the middle workspace, just like drag a QPushButton into workspace.
              After I drag my “Cusrom Widget”into the middle workspace, name it myWidget, i want to drag a QPushButton into myWidget.
              But myWidget does not accept.
              If I drag a QTabWidget into the workspace, name it myTab, i can drag a QPushButton into myTab.
              I want to ask how to design a customwidgetplugin like QTabWidget that could accept other control widget.
              Read English is easy, but hard to write.

              1 Reply Last reply Reply Quote 0
              • G
                goetz last edited by

                You should implement

                @
                bool isContainer() const;
                @

                and have it return true for your widget plugin.

                See "QDesignerCustomWidgetInterface":http://doc.qt.nokia.com/4.7/qdesignercustomwidgetinterface.html for details.

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply Reply Quote 0
                • Y
                  yaoyulian last edited by

                  [quote author="Volker" date="1288799498"]You should implement @ bool isContainer() const; @ and have it return true for your widget plugin. See "QDesignerCustomWidgetInterface":http://doc.qt.nokia.com/4.7/qdesignercustomwidgetinterface.html for details.[/quote]
                  Yes. It's taking effect.
                  Thank you!!

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post