Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Using Designer Ui file in application
Forum Updated to NodeBB v4.3 + New Features

Using Designer Ui file in application

Scheduled Pinned Locked Moved QML and Qt Quick
17 Posts 3 Posters 7.0k 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.
  • J Offline
    J Offline
    Julie1986
    wrote on last edited by
    #6

    I have experience with QML, C++ WIDGETS no idea abt designer.ui or c++QgraphicsView. I see that i can place items like VB in mainwindow.ui but I dont know how and where to write the code for the particular functionality. I hope you understand the problem I want a sample code containing the components in .ui window and the code in cpp format so that i can learn. THanks for your help. I greatly appreciate it.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      CreMindES
      wrote on last edited by
      #7

      Just take a look at Qt Creator's built in examples. It's a good starting point ;)

      1 Reply Last reply
      0
      • JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #8

        You're welcome. I hope I've understood correctly: You have used QML before, and you have written QWidgets in C++ before. Now, you now want to learn how to create GUI elements with Designer, and combine them with your existing QML application. Is that right?

        If so, then it's quite complicated. May I ask why you want to integrate Designer with QML?

        Anyway, here are the steps you need to take:

        First, learn how to integrate QML with your existing C++ QWidgets. The example is in the link you posted, under "Integrating with a QWidget-based UI" -- Just create a QDeclarativeView (it's a C++ widget) and pass it your QML file.

        Second, learn how to use Designer by itself. I'll explain this more below.

        Third, learn how to integrate Designer widgets and your custom C++ widgets. You need to learn how to "promote widgets":http://qt-project.org/doc/qt-4.8/designer-using-custom-widgets.html#promoting-widgets.

        Finally, you take the QDeclarativeView that uses your QML file, and promote it in Designer.

        [quote author="Julie1986" date="1345803346"]I see that i can place items like VB in mainwindow.ui but I dont know how and where to write the code for the particular functionality[/quote]
        This is for Step #2. If you use Qt Creator to create a new "Qt GUI application", it will automatically create 3 files for you: mainwindow.ui, mainwindow.cpp, mainwindow.h. Your functionality code goes into mainwindow.cpp, just like a normal C++ QWidget

        When you place items in "VB-mode", you can also set their objectName (which is a C++ variable) in the bottom-right corner of your screen. For example, if I insert a Push Button item and set its objectName to "pushButton_quit", I can write this in mainwindow.cpp:

        @
        MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
        {
        ui->setupUi(this);

        connect(ui->pushButton_quit, SIGNAL(clicked()), this, SLOT(close())); // I only added this line. The others were automatically-generated
        }
        @

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Julie1986
          wrote on last edited by
          #9

          Oh cool.. I understood the logic now.. Thanks a lot.. if I have to integrate this file in qml i need to use that Quiloader right??

          My Boss wants me to have a research on the integration part of qml with Qt ui.:(

          1 Reply Last reply
          0
          • JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #10

            [quote author="Julie1986" date="1345811357"]if I have to integrate this file in qml i need to use that Quiloader right??[/quote]
            As far as I know, you can't integrate mainwindow.ui into QML. :( You can:

            • Integrate mainwindow.ui into mainwindow.cpp automatically
            • Integrate mainwindow.ui into your_other_cpp_gui.cpp, using QUiLoader
            • Integrate your_other_qml_gui.qml into [anything].cpp, using QDeclarativeView

            To combine both QML and Designer, you need to write your code in C++ using

            • QDeclarativeView + QUiLoader, or
            • QDeclarativeView + (promoting widgets in Designer)

            [quote author="Julie1986" date="1345811357"]My Boss wants me to have a research on the integration part of qml with Qt ui.:([/quote]
            Ah... sometimes bosses ask for difficult things. Good luck.

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply
            0
            • J Offline
              J Offline
              Julie1986
              wrote on last edited by
              #11

              :) lol thanks for your time JKSH. You were really kind enough to offer your help. Appreciate it.

              1 Reply Last reply
              0
              • JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote on last edited by
                #12

                No problem :) I wish you all the best

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  Julie1986
                  wrote on last edited by
                  #13

                  Hey I found this http://doc.qt.nokia.com/4.7-snapshot/qml-integration.html

                  will this solve my problem?? my boss basically wants qml file running back ground with qtwidgets in front

                  1 Reply Last reply
                  0
                  • JKSHJ Offline
                    JKSHJ Offline
                    JKSH
                    Moderators
                    wrote on last edited by
                    #14

                    That's the article in your original post, right? I've read it already, and incorporated it into my 2nd-last post (above this one).

                    I've never heard of placing a C++ QWidget inside a QML program, sorry... it might be possible, but I've never seen it done. The closest thing I can think of is using C++ QGraphicsWidget in front, as described in the article. Note that QGraphicsWidget is very different from QWidget, and it is not supported by Designer. QGraphicsWidget belongs in the Graphics View Framework, which is separate from the QWidget framework.

                    QML is very graphics-oriented. Some people would even say that QML is meant to replace Designer and C++ QWidgets. To get rid of QML graphics and replace them with older QWidgets seems a little backwards, and isn't well-supported, IMHO.

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    1 Reply Last reply
                    0
                    • J Offline
                      J Offline
                      Julie1986
                      wrote on last edited by
                      #15

                      thanks JKSH for the info.:)

                      1 Reply Last reply
                      0
                      • J Offline
                        J Offline
                        Julie1986
                        wrote on last edited by
                        #16

                        Hey JKSH do you have any idea on this??

                        its my new query:)

                        http://qt-project.org/forums/viewthread/19937/

                        1 Reply Last reply
                        0
                        • J Offline
                          J Offline
                          Julie1986
                          wrote on last edited by
                          #17

                          the post is [Solved] not the previous comment.:)

                          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