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. How to re-use a Widget inside another project - NEWBIE
Forum Updated to NodeBB v4.3 + New Features

How to re-use a Widget inside another project - NEWBIE

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.1k 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.
  • MikluxM Offline
    MikluxM Offline
    Miklux
    wrote on last edited by
    #1

    Hi all,
    this is my first post and I'm a ** very newbie ** in Qt programming and not very newbie in general OOP.
    I'm trying to understand how to reuse some widget that I created (in other projects) in new projects.
    I try to explain better.
    I created a widget (with its ui and many files .cpp and .h).
    Now I want to create a mainwindow where put a certain number of these widgets and I hope to see every widget inside my mainwindow in a fixed position.
    Every time that I want to add a new widget, the new position will be near to the previously widget created.
    I want that every widget can be removed using a button on the same widget.

    How can I do this operations?
    Can you suggest some way?
    Sorry if the question is banal but I really don't full understand Qt methods and classes.

    ** Thank you ** in advance for every help you will give me! ;)
    Mik

    Ni.SumiN 1 Reply Last reply
    0
    • MikluxM Miklux

      Hi all,
      this is my first post and I'm a ** very newbie ** in Qt programming and not very newbie in general OOP.
      I'm trying to understand how to reuse some widget that I created (in other projects) in new projects.
      I try to explain better.
      I created a widget (with its ui and many files .cpp and .h).
      Now I want to create a mainwindow where put a certain number of these widgets and I hope to see every widget inside my mainwindow in a fixed position.
      Every time that I want to add a new widget, the new position will be near to the previously widget created.
      I want that every widget can be removed using a button on the same widget.

      How can I do this operations?
      Can you suggest some way?
      Sorry if the question is banal but I really don't full understand Qt methods and classes.

      ** Thank you ** in advance for every help you will give me! ;)
      Mik

      Ni.SumiN Offline
      Ni.SumiN Offline
      Ni.Sumi
      wrote on last edited by Ni.Sumi
      #2

      @Miklux

      I'm trying to understand how to reuse some widget that I created (in other projects) in new projects.

      You can simply make new and you can use your own widget. Also check this "Promote widget in Qt Designer"
      Eg: MyWidget * gh = new MyWidget; //you will have copy of MyWidget and can access all the functiosn signals and slots inside it.

      Now I want to create a mainwindow where put a certain number of these widgets and I hope to see every widget inside my mainwindow in a fixed position.Every time that I want to add a new widget, the new position will be near to the previously widget created.

      You can use Layouts to set the position of the widgets basing on your requirement.

      I want that every widget can be removed using a button on the same widget.

      If "MYWidget " derived from the QDialog or something like this, you will have close by default. If not , You can set close button on your MyWidget and add the close functionality to it.

      MikluxM 1 Reply Last reply
      1
      • Ni.SumiN Ni.Sumi

        @Miklux

        I'm trying to understand how to reuse some widget that I created (in other projects) in new projects.

        You can simply make new and you can use your own widget. Also check this "Promote widget in Qt Designer"
        Eg: MyWidget * gh = new MyWidget; //you will have copy of MyWidget and can access all the functiosn signals and slots inside it.

        Now I want to create a mainwindow where put a certain number of these widgets and I hope to see every widget inside my mainwindow in a fixed position.Every time that I want to add a new widget, the new position will be near to the previously widget created.

        You can use Layouts to set the position of the widgets basing on your requirement.

        I want that every widget can be removed using a button on the same widget.

        If "MYWidget " derived from the QDialog or something like this, you will have close by default. If not , You can set close button on your MyWidget and add the close functionality to it.

        MikluxM Offline
        MikluxM Offline
        Miklux
        wrote on last edited by
        #3

        @Ni.Sumi

        Great!
        Tomorrow I will try your suggestions and will give you a feedback

        Thank you very much
        Mik

        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