Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Table editor for my own widget

Table editor for my own widget

Scheduled Pinned Locked Moved Qt Creator and other tools
14 Posts 3 Posters 8.4k Views
  • 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.
  • M Offline
    M Offline
    MasterMatrix
    wrote on last edited by
    #1

    Hello!

    In the form's editor QtCreator at double click on QTableWidget there is form Edit Table Widget (on a screenshot) in which it is possible to set columns, rows, their values, headers, etc.
    How it is possible to make for own widget the similar form (Edit My Widget for example) which is caused from the editor? To set number of columns and other...

    !http://img-fotki.yandex.ru/get/5700/lenvampir.2/0_4cd62_1bc903fd_L(Screenshot)!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      I have never tried this, but a quick look through the documentation suggests that perhaps QDesignerTaskMenuExtension can help you. It allows you to add actions to the task menu (design context menu) of your widget. That is just a QAction. I would think, that you can pop up any form from your plugin code to configure your widget that you can dream up. I don't know how to store that additional data in your .ui file however, but I guess that's a different topic :-)

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MasterMatrix
        wrote on last edited by
        #3

        Thanks for the answer, Andre, but I think that it not absolutely that is necessary.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          There is a complete "Task Menu Extension Example":http://doc.trolltech.com/4.7/designer-taskmenuextension.html in the Qt docs on how to do this.

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

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MasterMatrix
            wrote on last edited by
            #5

            Thanks for the answer, we'll see how to use it :)

            1 Reply Last reply
            0
            • M Offline
              M Offline
              MasterMatrix
              wrote on last edited by
              #6

              I'll try to explain what I meant. How can I implement "edit items" in my widget the same way as in QTableWidget (via context menu in some complex dialog)? Here is some screenshots.

              !http://img526.imageshack.us/img526/5402/edititems1j.png(Step1)!

              !http://img827.imageshack.us/img827/9596/edititems2.png(Step2)!

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                From what I understand, you have to design that dialog yourself and make it part of the Designer plugin. You can use the QDesignerTaskMenuExtension to put the menu item in the context menu for the widget.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  MasterMatrix
                  wrote on last edited by
                  #8

                  Thanks, Andre! And what if we need this widget available in Qt Designer?

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andre
                    wrote on last edited by
                    #9

                    Did you actually read and understand anything of all the messages above?
                    I mean, the whole point of creating a designer plugin, is to make your widget available in Qt Designer. Do you at least have that part working? Can you see your own widget appearing in Designer?

                    If not, I suggest you take a look at the example on how to do it. "This page":http://doc.qt.nokia.com/4.7/designer-creating-custom-widgets.html would be the place to start.

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      goetz
                      wrote on last edited by
                      #10

                      You have to implement the editor yourself. The code must go into the Qt Designer plugin. You also must must add some code to put the data you added to your widget into the generated .ui file and there must be some means to generate the C++ code to populate your widget once uic generates the ui_xxx.h file. I don't know if the latter is possible. Designer's source might be a good point to start of - just look at the editors for the table widgets that are provided there.

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

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        MasterMatrix
                        wrote on last edited by
                        #11

                        To Andre:
                        Yes, i have already my own widget, and it's working in some programms. And i would like to crate editor for this widget.
                        Thank you for showing me to QDesignerTaskMenuExtension? it may be one of the start point.

                        To Volker:
                        Thank you for your thorough answer. The problem is I do not know where to get that source of editor for Table-Widget. I know where is QtDesigner's source, but i can't find folder exactly with Table Widget's source.

                        1 Reply Last reply
                        0
                        • G Offline
                          G Offline
                          goetz
                          wrote on last edited by
                          #12

                          Have a look at the directory tools/designer/src in your Qt source. There are some tablewidgetxxx files that look promising.

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

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            MasterMatrix
                            wrote on last edited by
                            #13

                            Oh, Volker, thank you very mach! It's exactly, what i need.
                            I'm happy :-)

                            1 Reply Last reply
                            0
                            • G Offline
                              G Offline
                              goetz
                              wrote on last edited by
                              #14

                              No problem, you're welcome. Maybe you can make a small wiki article, once you have it working. I guess, this question will pop up once in a while...

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

                              1 Reply Last reply
                              0

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved