Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Combine forms and classes dynamically
Forum Updated to NodeBB v4.3 + New Features

Combine forms and classes dynamically

Scheduled Pinned Locked Moved General and Desktop
14 Posts 6 Posters 8.9k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    blenkhn
    wrote on last edited by
    #3

    I am not sure about that forum.

    I am thinking I am not describing what I am after properly. I have in my project 2 forms the mainwindow and invoice. When I added invoice to my project in creator, I got it to build a class at that time. Not sure if it was a good idea.

    I want the invoice form incorporated into a tab in the mainwindow form. Dynamically if possible? I want to be able to do this so that I can add Information to the tab text.

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vsorokin
      wrote on last edited by
      #4

      blenkhn, you may make Form class with QtCreator class form wizard (As I understand, you need QWidget subclass).
      After, you should include header of your invoice form class to mainwindow and
      will create object of your invoice widget.
      And after you should add you invoice object to mainwindow layout.

      --
      Vasiliy

      1 Reply Last reply
      0
      • I Offline
        I Offline
        infoctopus
        wrote on last edited by
        #5

        bq. So how do I include the entire invoice class and all into a dynamically created tab?bq.

        Your invoice form is a widget (QWidget descendant)
        You create your invoice form widget and add it to a new tab.

        @InvoiceWidget *myNewInvoiceWidget = new InvoiceWidget(...);
        myTabWidget->addTab(myNewInvoiceWidget, QString("Invoice #%1").arg(++invoiceNum));@

        Qt rulez

        1 Reply Last reply
        0
        • B Offline
          B Offline
          blenkhn
          wrote on last edited by
          #6

          Thanks for the reply infoctopus, I don't like to sound like a total newbie but the (...) is the name of the .h file or the ui file? In this case InvoiceToolBox.h and InvoiceToolBox.ui, does this method also embed the class, Invoicetoolbox.cpp? If I wanted to see this on startup how would I include it in the main.cpp?

          @#include <QtGui/QApplication>
          #include "mainwindow.h"
          #include "invoicetoolbox.h"

          int main(int argc, char *argv[])
          {
          QApplication a(argc, argv);
          MainWindow w;
          InvoiceToolBox i;
          w.show();
          InvoiceWidget *myNewInvoiceWidget = new InvoiceWidget(InvoiceToolBox.h);
          myTabWidget->addTab(myNewInvoiceWidget, QString("Invoice #%1").arg(++invoiceNum));

          return a.exec&#40;&#41;;
          

          }
          @

          1 Reply Last reply
          0
          • I Offline
            I Offline
            infoctopus
            wrote on last edited by
            #7

            blenkhn, don't afraid to sound like a newbie, be afraid to miss important things :)
            Generally I think that now is a good time to read some book on C++ basics.

            InvoiceWidget is a QWidget. You can see its constructor in Assistant.

            Qt rulez

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

              There is a good documentation in "Using a Designer UI File in Your Application":http://doc.qt.nokia.com/latest/designer-using-a-ui-file.html on how to make your Designer created UI work with your code.

              Basically you should:

              • Create your UI with Designer
              • choose one of the three methods mentioned in the docs (see the link)
              • Then you can call new InvoiceWidget(this) and put that in your code.

              Despite that, a good C++ introduction would be of help, as infoctopus wrote.

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

              1 Reply Last reply
              0
              • I Offline
                I Offline
                infoctopus
                wrote on last edited by
                #9

                a good C++ introduction is of extreme need, not just help
                blenkhn, don't treat that as a mentoring, it's a real need for you. You'd like it all :)

                Qt rulez

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  blenkhn
                  wrote on last edited by
                  #10

                  Hey Guys thanks for the help, I am looking at some books online to buy. I am not new to programming and thought my background in perl would help, but there are language differences. modules instead of classes and the methodology seems to be a little different.

                  Do you have any suggestions as to a good book or online tutorial? I have been reading learncpp.com but I thought I could skip a couple of lessons as they seemed to be mostly basic lessons - guess I shouldn't be trying to skip ahead.

                  I have both ui's built and I have read the page Volker linked to and I would like to use the qtuitools as I feel a need to have multiple invoices open so that I could go back to an invoice and add information to it as needed. Right now I was wanting to see if I could get the second ui to load into a tab page on the first ui. After that should be fairly simple to get it into a tab with a button click. Can you guys help with an example?

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    fcrochik
                    wrote on last edited by
                    #11

                    Look at:
                    http://developer.qt.nokia.com/forums/viewthread/2069/

                    and

                    http://developer.qt.nokia.com/wiki/Books_and_Links_for_learning_C_and_advanced_topics

                    Certified Specialist & Qt Ambassador <a href="http://www.crochik.com">Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop... Qt everywhere!</a>

                    1 Reply Last reply
                    0
                    • I Offline
                      I Offline
                      infoctopus
                      wrote on last edited by
                      #12

                      As for C++ +Qt book, I'd recommend "An Introduction to Design Patterns in C plus plus with Qt 4" by Alan Ezust and Paul Ezust

                      it's even free: http://cartan.cas.suffolk.edu/oopdocbook/html/

                      Qt rulez

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

                        [quote author="blenkhn" date="1291675356"]Hey Guys thanks for the help, I am looking at some books online to buy. I am not new to programming and thought my background in perl would help, but there are language differences. modules instead of classes and the methodology seems to be a little different.[/quote]

                        Perl is not really helpful in that case, I must admit. I came from that background too. Things are quite different. You need to get comfortable with header files/includes, compilation units and how all these things fit together.

                        [quote author="blenkhn" date="1291675356"]I have both ui's built and I have read the page Volker linked to and I would like to use the qtuitools as I feel a need to have multiple invoices open so that I could go back to an invoice and add information to it as needed. Right now I was wanting to see if I could get the second ui to load into a tab page on the first ui. After that should be fairly simple to get it into a tab with a button click. Can you guys help with an example?[/quote]

                        I can only recommend, that you start from scratch. You should make yourself comfortable with the principles of programming in C++, the basic Qt concepts (widgets, form files created with designer, combining them together), then how to add widgets using C++, and so forth. Don't make too big steps in the beginning, it will not work and is frustrating.

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

                        1 Reply Last reply
                        0
                        • F Offline
                          F Offline
                          fcrochik
                          wrote on last edited by
                          #14

                          [quote author="infoctopus" date="1291676411"]As for C++ +Qt book, I'd recommend "An Introduction to Design Patterns in C plus plus with Qt 4" by Alan Ezust and Paul Ezust

                          it's even free: http://cartan.cas.suffolk.edu/oopdocbook/html/[/quote]

                          Please make sure to add this reference to the books wiki.

                          Certified Specialist & Qt Ambassador <a href="http://www.crochik.com">Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop... Qt everywhere!</a>

                          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