Results 1 to 4 of 4

Thread: promotion problems with designer

  1. #1
    Join Date
    Nov 2010
    Location
    Budapest, Hungary
    Posts
    125
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default promotion problems with designer

    Hi,

    I have a small class derived from QPushButton for the cases whenever I need a file loader button, and I use my class with the promotion technique. I work on XP, and I use the Qt Creator. Whenever I change something in the after I try to build the project I get the error message:
    buttonfledialog.h: No such file or directory.

    This appears in the generated ui header at the line where it tries to include my buttonfiledialog.h like this:
    #include <buttonfiledialog.h>
    which of course causes the error message.

    The problem can be solved with changing this line to
    #include "mypath/buttonfiledialog.h"
    but in this case I will have the very same problem whenever I change something in the user interface because the ui header will be every time regenerated with the wrong include line.

    Now I would like to ask if there is a way to avoid this mess, so how can I "teach" the creator (or the system itself, like adding a line into the pro file) to use the proper path?
    Szilvi

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: promotion problems with designer

    HI,

    as you can see in image

    promote.JPG

    you can specify namespace for class name and path for include.
    If you check "Global Include" uic generates
    Qt Code:
    1. #include <ns/mybutton.h>
    To copy to clipboard, switch view to plain text mode 

    instead of

    Qt Code:
    1. #include "ns/mybutton.h"
    To copy to clipboard, switch view to plain text mode 

    this is the output in "ui_Widget.h"

    Qt Code:
    1. #include "ns/mybutton.h"
    2.  
    3. ...
    4.  
    5. class Ui_Widget
    6. {
    7. public:
    8. ...
    9. Ns::MyButton *openFileButton;
    10. ...
    To copy to clipboard, switch view to plain text mode 
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Nov 2010
    Location
    Budapest, Hungary
    Posts
    125
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: promotion problems with designer

    if I do this:
    Promoted class name: NS::buttonFileDialog
    the automatic header file name will be ns_buttonfiledialog.h in the third line. Which generates in the ui_mainwindow.h this line:
    #include "ns_buttonfiledialog.h"
    which is of course wrong.

    I tried to use my own path, so in the three input areas have:
    Base class name: QPushButton
    Promoted class name: NS::buttonFileDialog
    Header file: D:/mypath/buttonfiledialog.h
    (and global include unchecked)
    which leads to errors because the namespace has not been created. I have error messages with this line in the generated ui header and furthermore wit each line in the other files where I use the button which was promoted to buttonFileDialog.

    But based on your advice I found the solution. The hard point was that I had the global include ticked, which is incorrect if I have the header in a custom folder on the computer. But I have never declared a custom namespace, so forcing this will obviously cause errors as well. The final answer is then not to use either the namespace or the global include.

    Base class name: QPushButton
    Promoted class name: buttonFileDialog
    Header file: D:/mypath/buttonfiledialog.h
    (and global include unchecked)
    Szilvi

  4. #4
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: promotion problems with designer

    Remember tha you can change the automatic proposed values in Promote Widget Dialog

    If you want to use "D:/mypath" as Include path I suggest you to do this

    Promoted class name: NS::buttonFileDialog
    Header file: buttonfiledialog.h
    (global include unchecked)

    AND

    add in your .pro file this line

    Qt Code:
    1. INCLUDEPATH += D:/mypath
    To copy to clipboard, switch view to plain text mode 
    A camel can go 14 days without drink,
    I can't!!!

Similar Threads

  1. Replies: 1
    Last Post: 8th September 2010, 19:31
  2. Replies: 1
    Last Post: 10th December 2009, 21:31
  3. Replies: 2
    Last Post: 1st October 2009, 16:26
  4. Problems with Designer for QActions
    By pherthyl in forum Qt Programming
    Replies: 1
    Last Post: 2nd November 2007, 22:10
  5. Replies: 1
    Last Post: 22nd January 2007, 12:13

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.