Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [SOLVED]Usage of "this" unknown in calling setupUi()
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Usage of "this" unknown in calling setupUi()

Scheduled Pinned Locked Moved Qt Creator and other tools
3 Posts 2 Posters 1.3k 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.
  • R Offline
    R Offline
    rajatgupta431
    wrote on last edited by
    #1

    May be this is due to my weak concepts in c++...In Qt i often see this line ui.setupUi( this ); or
    ui->setupUi(this) ;. I understand that , ui is the object that is used to call the function setupUI(). But i don't understand , what is "this"?? y is it passed to setuUi() ??

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Code_ReaQtor
      wrote on last edited by
      #2

      "this" means the "current class" where the code was written.

      ui->setupUI(this); needs a pointer of the current class (mainwindow) to be able to populate it with widgets. this pointer is needed since it will become a parent to the widgets you want to add.

      In Qt Creator, try hovering your mouse to setupUI() then press F2. you will be sent to the implementation.

      Please visit my open-source projects at https://github.com/Code-ReaQtor.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rajatgupta431
        wrote on last edited by
        #3

        [quote author="Code_ReaQtor" date="1358310836"]"this" means the "current class" where the code was written.
        . this pointer is needed since it will become a parent to the widgets you want to add.

        [/quote]
        Thanks a lot, you gave me the exact explanation .

        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