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. Accessing the C++ code of objects created in Designer?
Forum Updated to NodeBB v4.3 + New Features

Accessing the C++ code of objects created in Designer?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.6k 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.
  • T Offline
    T Offline
    thinkpad20
    wrote on last edited by
    #1

    Is there a way to get access to all of the code that the designer (WYSIWYG layout editor) writes automatically? All I can see is the XML; I'm looking for stuff like where and how the objects are initialized, etc. I assume (could be wrong) that all of this stuff is going on under the hood somewhere. As a Qt beginner it's great to have it do so much for me, but there are many things it does I'd like to see exactly how it's doing them, be able to do tweak myself in code, etc. Is this possible, or does creating stuff in the designer mean certain code is unavoidably hidden?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      When you run qmake, it automatically invokes uic (ui-compiler). What it does is, it takes .ui XML files and generates a header file "ui_<filename>.h" that is then used in your code. You can take a look into that file any time you like, just remember it will be regenerated automatically, so changing it by hand is a bad idea. As to where this file/ files are being stored, it depends on the .pro file, but typically they will sit together with remaining build objects (.o etc).

      (Z(:^

      1 Reply Last reply
      0
      • T Offline
        T Offline
        thinkpad20
        wrote on last edited by
        #3

        Hmm, I see, so they're quite different. That's kind of unfortunate :( thanks though.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Swatwork
          wrote on last edited by
          #4

          If you want more control over how the UI elements are created you could just create them directly in your code; you don't have to use the designer.

          If you don't already have it, the book 'C++ GUI Programming with Qt4' covers this approach in some detail. More information here: http://www.qtrac.eu/marksummerfield.html

          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