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. add C++ objects in Qt gui
Forum Updated to NodeBB v4.3 + New Features

add C++ objects in Qt gui

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 279 Views 2 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
    Markeggi
    wrote on last edited by
    #1

    Hello everyone,
    I started using QT yesterday so feel free to be rude to me.

    I looked at some docs to get started but I couldn't find myself with it.

    I created 2 frames in the Qt Creator Design Tab, but I want to add/edit some buttons to these Frames programmatically.

    My goal is to create:

    • 2 frames (already created using QWidgets) 1 of them is contained by a QscrollableArea so I can scroll between some Buttons that I added using widgets.

    I'll attach a photo of my render, so my question is, how can I create a new Widget in the mainwindow.cpp? When I tried doing so he showed a "secondary" window in addition to the Design GUI I already had.

    forum.png

    Thanks in advance!

    jsulmJ S 2 Replies Last reply
    0
    • Christian EhrlicherC Christian Ehrlicher moved this topic from Qt Creator and other tools on
    • M Markeggi

      Hello everyone,
      I started using QT yesterday so feel free to be rude to me.

      I looked at some docs to get started but I couldn't find myself with it.

      I created 2 frames in the Qt Creator Design Tab, but I want to add/edit some buttons to these Frames programmatically.

      My goal is to create:

      • 2 frames (already created using QWidgets) 1 of them is contained by a QscrollableArea so I can scroll between some Buttons that I added using widgets.

      I'll attach a photo of my render, so my question is, how can I create a new Widget in the mainwindow.cpp? When I tried doing so he showed a "secondary" window in addition to the Design GUI I already had.

      forum.png

      Thanks in advance!

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Markeggi You can access UI designed in designer from C++ code using ui-> pointer

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Markeggi

        Hello everyone,
        I started using QT yesterday so feel free to be rude to me.

        I looked at some docs to get started but I couldn't find myself with it.

        I created 2 frames in the Qt Creator Design Tab, but I want to add/edit some buttons to these Frames programmatically.

        My goal is to create:

        • 2 frames (already created using QWidgets) 1 of them is contained by a QscrollableArea so I can scroll between some Buttons that I added using widgets.

        I'll attach a photo of my render, so my question is, how can I create a new Widget in the mainwindow.cpp? When I tried doing so he showed a "secondary" window in addition to the Design GUI I already had.

        forum.png

        Thanks in advance!

        S Offline
        S Offline
        SimonSchroeder
        wrote on last edited by
        #3

        @Markeggi said in add C++ objects in Qt gui:

        how can I create a new Widget in the mainwindow.cpp

        Widgets should have a parent set upon creation (which would most likely be your main window in this case). Adding widgets to layouts also reparents them to the layout's widget. You should be using layouts for everything.

        One way is to call setCentralWidget() on the main windows to set the widget which is the main part of the main windows. Otherwise set a plain QWidget as the central widget, add a layout to it and then add your widget from the Qt Designer and your own widget to the layout.

        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