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. QT Creator - Instantiating multiple elements/templates with callbacks and others
Forum Updated to NodeBB v4.3 + New Features

QT Creator - Instantiating multiple elements/templates with callbacks and others

Scheduled Pinned Locked Moved Unsolved General and Desktop
designerui object
2 Posts 2 Posters 174 Views
  • 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.
  • F Offline
    F Offline
    FranFM
    wrote on 6 Nov 2024, 16:38 last edited by
    #1

    Hello everyone.
    I started learning Qt and there are a few things I do not know how to approach:

    1. I come from a game development (Unity) environment and I am used to the concept of simple "prefabs" or "templates" with attached classes. I could not find anything similar to that besides "Custom Widgets", but these do not behave in a logical way (?). Custom Widgets, if I understood correctly, are separate projects by themselves; this makes them not really usable for small projects and such. This is what I want to do:
      I have a Vertical Layout. Every time I click the button "Add Window", I want to instantiate a row with multiple buttons. Each button would end up calling a generic method by index (0, Total_Rows].
      I thought of simply generating every element through code but this sounds extremely tedious and does not make a lot of sense considering there is a UI/Drag&Drop editor. It defeats the purpose of easily editing the looks of the app.
      28413b10-1861-4d70-a4ba-fb4a09984b9c-image.png e0b589d0-7ed0-406c-a6c3-40c3cb9a98f9-image.png

    2. I have a few layouts and I would like to set their position through value just like I would with any other Widget but I dont get that in the Property Editor window. Is there a way of doing so?
      d16c9c60-0a20-4c01-a136-25664d1339c0-image.png

    3. Is it possible to make Widget elements to snap to the grid when moving them, not only when resizing? I find it very obnoxious to end up specifying the position values of labels & buttons through the Property Editor when I simply want to move them horizontally, for example.

    I'd appreciate pointers/guidelines or references to specific documentation. I am not the sharpest tool in the shed and it is taking me a lot to learn Qt & C++ at the same time.
    Thank you very much.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 6 Nov 2024, 16:54 last edited by
      #2

      Normally you don't set any fixed values for layouts or widgets so no - no snapping since not needed in the normal usecase.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0

      1/2

      6 Nov 2024, 16:38

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved