Results 1 to 2 of 2

Thread: Implementation in header, Qt forms, double compilation

  1. #1
    Join Date
    May 2011
    Posts
    30
    Thanks
    1

    Question Implementation in header, Qt forms, double compilation

    I have stuck on the following problem. I think it is mostly related to general programming issues.
    I have a class with implementation in header file. I include it in a .dll (where it is supposed to be) and .exe. I suppose that the binary code for this class will be in the .dll file and .exe file, am I right?

    Then imagine that there is a basic Qt form in a dll with exports flag. Generally, one have to include "ui_Form1.h" into an interface header file of the form's class, like this:

    Qt Code:
    1. #include "ui_Form1.h"
    2.  
    3. class DllFileExport Form1 : public QWidget
    4. {
    5. ...
    6. Ui::Form1 ui;
    7. }
    To copy to clipboard, switch view to plain text mode 

    When one uses this header in one of main project (.exe) files it means that the same code for Ui::Form1 class that has implementation in its header is compiled twice, in .dll and in .exe. That means that unnecessary (just rubbish) code will appear in .exe. It will not be used in .exe but this is not restricted as it is a basic non-private class of global scope.

    The idea of this approach was to store dialogs and custom widgets with forms in another module which could be replaced by the same module with bug fixes.

    What is the main approach of avoiding unnecessary double compilation of ui form class in .exe and .dll files?

    I suppose I should make a private class as a main dialog's class and a public class that inherits private class. With this approach header for ui from class will be hided within .dll module files that won't be included into main project which means no double compilation of the same code. Am I right?

    Another approach is to make uic for Qt 4 generate interface and implementation for ui form files in two different files: .h and .cpp. I haven't found any uic keys to make this. Does anyone know about any?
    Last edited by zzz9; 28th November 2012 at 13:42.

  2. #2
    Join Date
    May 2011
    Posts
    30
    Thanks
    1

    Default Re: Implementation in header, Qt forms, double compilation

    I have solved the problem using UI form layout class as a pointer to forward declared class.

Similar Threads

  1. Qt Creator Vertical split to visualize both header and implementation
    By akiross in forum Qt Tools
    Replies: 1
    Last Post: 16th July 2012, 14:05
  2. Replies: 8
    Last Post: 8th August 2011, 21:47
  3. QTreeWidget Horizontal header double click event???
    By deepal_de in forum Qt Programming
    Replies: 3
    Last Post: 6th June 2011, 09:31
  4. Multiple Forms and vertical layout in forms
    By eva2002 in forum Qt Programming
    Replies: 0
    Last Post: 13th January 2010, 06:05
  5. Double header
    By zedava in forum Qt Programming
    Replies: 5
    Last Post: 26th July 2009, 10:40

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.