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. Use the script engine to alter your GUI
Qt 6.11 is out! See what's new in the release blog

Use the script engine to alter your GUI

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.7k 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.
  • ealioneE Offline
    ealioneE Offline
    ealione
    wrote on last edited by
    #1

    Hey everyone,

    I was wondering whether it is possible to use the script engine to for example add a new button or some other widget to my main apps' gui?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JulienMaille
      wrote on last edited by
      #2

      Sure you can. I do it in my application.
      All I do is that I "expose" the QMainWindow and then I can access and modify its sub-objects.

      @ _eng->globalObject().setProperty("Main", _eng->newQObject(mainWindow));@

      1 Reply Last reply
      0
      • ealioneE Offline
        ealioneE Offline
        ealione
        wrote on last edited by
        #3

        Hey Julien,

        This is not exactly what I had in mind, I don't want to make an objects' public slots available to the engine but ad a new widget that did not even exist in the beginning of the program. Until now the best thing I could find was to create a new custom object that inherits the widget I want and use a function that when called will create the aforementioned (and only that) widget. I was wondering if there are other ways, or if even this is a good idea to begin with. I am doing this as an exercise and to be honest can't think how it can actually be useful, except maybe for the case when a user would be able to create his own gui, or customise an existing one.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          JulienMaille
          wrote on last edited by
          #4

          My point was that once you have access to Main, then you can easily insert your script-created widgets into an existing Toolbar, layout or DockWidget.

          1 Reply Last reply
          0
          • ealioneE Offline
            ealioneE Offline
            ealione
            wrote on last edited by
            #5

            Indeed, and you are absolutely right in that regard. What is not very clear to me at this point though is how can I create a new widget from inside my script, something that I should have stated more clearly in my question.

            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