PDA

View Full Version : promotion problems with designer



szisziszilvi
22nd April 2011, 07:52
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?

mcosta
22nd April 2011, 09:56
HI,

as you can see in image

6278

you can specify namespace for class name and path for include.
If you check "Global Include" uic generates


#include <ns/mybutton.h>


instead of



#include "ns/mybutton.h"


this is the output in "ui_Widget.h"



#include "ns/mybutton.h"

...

class Ui_Widget
{
public:
...
Ns::MyButton *openFileButton;
...

szisziszilvi
26th April 2011, 07:58
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)

mcosta
26th April 2011, 08:27
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



INCLUDEPATH += D:/mypath