Results 1 to 5 of 5

Thread: How to interface Qt Quick UI code with Qt creator pluing?

  1. #1
    Join Date
    Apr 2014
    Posts
    125
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Android Maemo/MeeGo

    Question How to interface Qt Quick UI code with Qt creator pluing?

    Hello;

    I'm trying to build a plugin for Qt Creator as described in [1] http://doc.qt.digia.com/qtcreator-ex...st-plugin.html.
    The plugin should use Qt Quick QML.

    I wonder how to insert this code from the main() function of a destktop Qt Quick app:
    Qt Code:
    1. QGuiApplication app(argc, argv);
    2. QQmlApplicationEngine engine("main.qml");
    3. QObject *root = engine.rootObjects().at(0);
    4. QQuickWindow *window =
    5. qobject_cast<QQuickWindow*>(root);
    6. if (!window) {
    7. qFatal("Error: No window found!");
    8. }
    9. window->show();
    10. return app.exec();
    To copy to clipboard, switch view to plain text mode 
    into the basic template plugin generated by Qt Creator.

    How to interface with:
    Qt Code:
    1. void ExamplePlugin::triggerAction()
    2. {
    3.  
    4. QMessageBox::information(Core::ICore::instance()->mainWindow(),
    5. tr("Action triggered"),
    6. tr("This is an action from Example."));
    7. }
    To copy to clipboard, switch view to plain text mode 
    Should my code for the Qt Creator plugin acts as a library of the template plugin?


    Thank you for any reply.
    Last edited by anda_skoa; 25th April 2014 at 11:04. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to interface Qt Quick UI code with Qt creator pluing?

    What have you tried already?

    You obviously don't need the QGuiApplication, that is already handled by Creator itself.
    You will want to keep the engine object alive, so you probably want it as a member of your plugin class.
    Creator calls the initialize() method of all plugins after they have been loaded, so that sounds like a good place to load the QML.

    Cheers,
    _

  3. #3
    Join Date
    Apr 2014
    Posts
    125
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Android Maemo/MeeGo

    Question How to inject Qt Quick QML into Qt Widget based desktop app;

    Hello

    I'm writing a desktop Qt Widget app for Windows. I want to do part of the UI in Qt Quick QML, hence I need to inject Qt Quick UI components
    into my existing Widget UI code.

    1) How to add one QQuickView on top of Core::ICore::instance()->mainWindow()?
    From Core::ICore::instance()->mainWindow()
    to
    QQuickView

    2) How to add one QQuickWindow on top of Core::ICore::instance()->mainWindow()? is this possible?
    From Core::ICore::instance()->mainWindow()
    to
    QQuickWindow

    Thank for any help.

  4. #4
    Join Date
    Mar 2014
    Location
    china
    Posts
    3
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: How to inject Qt Quick QML into Qt Widget based desktop app;

    you can use a QML file as source,like the picture source

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to inject Qt Quick QML into Qt Widget based desktop app;

    If you want to add your QtQuick view into a widget layout, you need to wrap it into a QWidget first and then add this

    Qt Code:
    1. // view constructed somewhere
    2. QQuickView *view ....
    3.  
    4. // create wrapper widget
    5. QWidget* viewContainer = QWidget::createWindowContainer(view);
    6.  
    7. // add widget as any other widget
    8. layout->addWidget(viewContainer)
    To copy to clipboard, switch view to plain text mode 

    With Qt 5.3 there will also be another alternative: QQuickWidget

    Cheers,
    _

Similar Threads

  1. Replies: 2
    Last Post: 22nd February 2012, 01:33
  2. Replies: 3
    Last Post: 1st February 2012, 01:18
  3. Qt Creator qt creator code model
    By Vanir in forum Qt Tools
    Replies: 0
    Last Post: 5th October 2010, 12:10
  4. Creator Interface Question
    By manilla_wise in forum Newbie
    Replies: 1
    Last Post: 10th August 2010, 00:53
  5. How to turn off translator code in creator
    By sanfordpaul in forum Newbie
    Replies: 0
    Last Post: 5th March 2009, 00:39

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.