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. QML and C++ interaction. Need advice
Forum Updated to NodeBB v4.3 + New Features

QML and C++ interaction. Need advice

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 892 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.
  • M Offline
    M Offline
    maksim1979
    wrote on last edited by
    #1

    Hello guys

    Again I need your help. I'm implementing some kind of multi-tab application where each tab holds an editor that in turn shows somehow a file content. The application components/layouts/etc are specified using QML, but the editor itself is written in C++. To be able to use C++ editor from QML, I'm using standard approach:
    @qmlRegisterType<MyEditor>("Specialeditor", 1, 0, "MyEditor");@

    So in my QML file I can do something like that:

    @import Specialeditor 1.0

    Rectangle {
    id:main
    ...
    MyEditor {
    ...
    }
    }@

    But now I would like to ask my editor to open a certain file (and it's not just a file name or string based content, in my case it would by specialy styled document that I have to prepare, I mean it's not a standard type that QML would understand). How I can ask certain editor (since I can have a lot of them) to show certain styled document (namely C++ object)?
    This way is not going to help as I understand:
    @viewer.rootContext()->setContextProperty(QStringLiteral("styledDocument"), getMyStyledDocument());@
    Since I cannot specify certain editor instance that has to open the document. Any thoughts?

    Thanks a lot,
    Maxim

    1 Reply Last reply
    0
    • U Offline
      U Offline
      unai_i
      wrote on last edited by
      #2

      Hi,
      I'm not sure I understood your question but if you give an id to your editors or if you know the indices of your tabs, you can call slots of your editor instances to perform specific actions in given editor. A slot is called like a javascript function: @myReference.calledFunction(args);@

      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