[Qt-interest] Menu bar on QtCreator created GUI

Malyushytsky, Alex alex at wai.com
Thu Jul 15 03:05:35 CEST 2010


What is the purpose of this widget you created after initializing ui?

If it is going to be a window, you may add  Qt::Window flag which should fix the problem.
QWidget* p = new QWidget(this, Qt::Window);

If it is going to be a dialog just it from the QDialog.
If you want to display this widget somewhere at the Central Widget area use centralWidget as a parent.

As is, I guess QMainWindow is not expecting to have children which are not created with Qt::Window flag.

I am still surprised that just creating QWidget child leads to blocking all interaction, and
I would assume this is a bug, cause it might affect ability to add graphical elements beside existing to QMainWindow,

But this might be not your case.
So either find proper parent or make sure that isWindow returns true ( derive from the different class , put flag, etc).

Hope this helps,
   Alex





-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of OSProg
Sent: Wednesday, July 14, 2010 3:31 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Menu bar on QtCreator created GUI

I hope I can send file here.
It looks like the QWidget takes all QMouseEvent-s and doesn't pass them to QMenuBar...
Regards,
Nik

> On 14/07/10 20:33, Constantin Makshin wrote:
>> That's strange.
>>
>> I've made a "quick and dirty" test application (see the attachment)
>> and everything works as expected.
>
> Wow, cool, thanks! :)
> I think it has to do with parenting. Weird... I have to see what I can do.
>
>> By the way, your connect() call looks a bit weird, too ? the signal
>> has a parameter, but the slot does not.
>
> The signal is that way, because the parameterless one is not emitted
> (I checked the source code), but I don't need the parameter.
>
> Regards,
> Oszkar
>
>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 14 Jul 2010 13:04:31 -0700
> From: "Malyushytsky, Alex" <alex at wai.com>
> Subject: Re: [Qt-interest] Menu bar on QtCreator created GUI
> To: "qt-interest at trolltech.com" <qt-interest at trolltech.com>
> Message-ID: <F8145CF983B4DB42855E9BB7F5BE8FCC48CE873E at camail2>
> Content-Type: text/plain; charset="utf-8"
>
> There is nothing wrong, I guess you are missing something else.
> I think you can get such behavior if you specify wrong parent for example.
> Make small example which demonstrate your problem.
> Attach source code and post it.
>
> Regards,
>     Alex
>
>
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com
> [mailto:qt-interest-bounces at trolltech.com] On Behalf Of OS Prog
> Sent: Wednesday, July 14, 2010 8:08 AM
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] Menu bar on QtCreator created GUI
>
> 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


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

“This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”

“Please consider our environment before printing this email.”




More information about the Qt-interest-old mailing list