[Qt-interest] Menu bar on QtCreator created GUI

OS Prog osprog at gmail.com
Wed Jul 14 17:08:01 CEST 2010


On Wed, Jul 14, 2010 at 2:36 PM, OS Prog <osprog at gmail.com> wrote:
>>> > ...
>>> The problem is when I run this application. I can see "File" and
>>> "Tools" texts on the QMenuBar, but when I click on them nothing
>>> happens - like I'm not clicking on them. The menu doesn't appear
>>> (this drop-down menu that should appear when you click on them with
>>> all the actions on it..).
>>
>> Okay, now I understand the problem. But are you really sure that nothing at all is displayed? Not even a tiny empty rectangle (the actual menu with no items in it)? And I mean really small, like a few pixels in height... this would indicate that the changes you did in Qt Creator - adding the menu items - are not reflected in either the *.ui file (you did not save) or the generated files (they are not re-generated or compiled/linked).
>>
> Nothing is displayed. Absolutely nothing. Even a pixel.
> The changes are applied, I think, as I've added the QMenu and the
> QActions on it at the same time and then I've build the code - The
> menu text is there but didn't worked. So I assume that files are
> generated correctly and I'm using the right build.
>
>> Also, are you sure you are not mixing up your debug/release binaries? Maybe you are building in release mode, but are starting the (outdated) debug binary?
>>
> Yes, the release folder is empty and I'm working only on debug one...
>
>> Anyway, I still assume that after you did your changes in Qt Creator that the resulting files are not properly auto-generated. Are you using qmake? I strongly assume so (since you mentioned Qt Creator). Make sure that in your *.pro file the UI files are proplery declared:
>>
>> FORMS += YourMainWindow.ui
>>
> They are.
>
>> qmake then takes care of the necessary steps (uic'ing, moc'ing). Do a 'make clean' (or in Qt Creator: right-click on the project(s) and "Clean") and see if that makes a difference...
> I've done it. Even I've cleaned all remaining files after 'clean' step
> manually and I've rebuild it.
>
> BTW, I've noticed that for the first time in Qt4.5 (don't remember
> QtCreator version) few months ago, but I worked around doing the menu
> stuff in the code, rather on the designer. Now I'm using Qt4.7b1 and
> QtCreator 1.3.83.
>
> I've tried building it on few machines (XP and Vista) - it's the same.
>
> Regards
> Nik
>
I've payed a bit to find out more.
It happened if I create a QWidget in the MainWindows constructor.
You can reproduce it if you create a MainWindow GUI with the creator
and put some menubar items on it.
Then in the MainWindow constructor, just after the
ui->setupUi(this);
put:
QWidget *wdg = new QWidget(this);

So, the question is: What's wrong putting the QWidget on this place
with parent MainWindow?

Best regards,
Nik




More information about the Qt-interest-old mailing list