Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / qt / 2007-07

PQtPoint, Menus and Qt IDE

19 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Paul Ishenin

Hello, Items specific to the Qt widget set.

Today I tried to fix some problems I had with starting QT ide (under windows).

As result I have:
- fixing "point" issues (change from PPoint to PQtPoint)
- fixing lazarus splash screen launch (there was assumption in the code that application already has MainForm, so all calls like Application.MainForm.Visible causes AV)
- fixing issues with Menu.

I want to add some notes about Menu.

Before changes and what errors we had:

We created TQtMenu if MenuItem.Count > 0 and TQtAction in other case. It works fine if our menu were completely defined before TQtWSMenuItem.CreateHandle calls. And in all TQtWSMenuItem we looked at MenuItem.Count to define wich class should we use TQtMenu/TQtAction.

Problems: if we add TMenuItem in runtime to some Item wich has 0 SubItems then we get AV since we will try to use TQtMenu where we have TQtAction.

After patch:

We always create TQtMenu in spite of MenuItem.Count. Every QMenu has internal QAction, so it is not a problem to get pointer to QAction where we need. As result we can add submenus at runtime without any troubles with defining internal widget class that represents TMenuItem.

After fixing this issues I've got ability to start Qt IDE. Screenshot: http://free1c.narod.ru/qt/qt_ide.png

Ofcource I can apply this patch myself, but I dont know if I right with "points" issues and with TQtWSMenuItem rework.

Best regards, Paul Ishenin. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: qt_intf.patch URL: <http://lists.lazarus.freepascal.org/pipermail/qt/attachments/20070709/16201e58/attachment.ksh>
Felipe Monteiro de Carvalho
to Paul Ishenin
Paul Ishenin wrote
After fixing this issues I've got ability to start Qt IDE. Screenshot: http://free1c.narod.ru/qt/qt_ide.png

Nice! I'm anxious to test it on my Mac.

Ofcource I can apply this patch myself, but I dont know if I right with "points" issues and with TQtWSMenuItem rework.

Yes, I think you got it right. When I implemented TQtMenu I didn't know about this possibility. Please apply the patch =)

thanks,

Felipe Monteiro de Carvalho
Paul Ishenin
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote
Yes, I think you got it right. When I implemented TQtMenu I didn't know about this possibility. Please apply the patch =)

Thanks for review. Commited.

Now I am looking why other controls overlaying MainMenu.

Best regards,
Paul Ishenin.

Felipe Monteiro de Carvalho
to Paul Ishenin
Paul Ishenin wrote
Now I am looking why other controls overlaying MainMenu.

I thougth I had already fixed this.

Now we have 2 controls on the form. A QMainWindow and a QWidget inside it. We put the controls inside the QWidget.

This was the only way I found to get automatic change of the 0,0 position for putting component when we have a menu present.

Felipe Monteiro de Carvalho
Paul Ishenin
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 11 lines
On 7/9/07, Paul Ishenin wrote: > Now I am looking why other controls overlaying MainMenu. I thougth I had already fixed this. Now we have 2 controls on the form. A QMainWindow and a QWidget inside it. We put the controls inside the QWidget. This was the only way I found to get automatic change of the 0,0 position for putting component when we have a menu present.

Yes, Felipe, previos code works fine.

This code cause overlaying MenuBar by other controls:

MDIAreaHandle := QMdiArea_create(Result);
CentralWidget := MDIAreaHandle;
QMainWindow_setCentralWidget(QMainWindowH(Result), MDIAreaHandle);
QMainWindow_setDockOptions(QMainWindowH(Result), QMainWindowAnimatedDocks);

This no:

CentralWidget := QWidget_create(Result);
QMainWindow_setCentralWidget(QMainWindowH(Result), CentralWidget);

If you know fast solution, please commit, or I will start my investigation.

Best regards,
Paul Ishenin.

zeljko
to Paul Ishenin
Paul Ishenin wrote 13 lines
This code cause overlaying MenuBar by other controls: MDIAreaHandle := QMdiArea_create(Result); CentralWidget := MDIAreaHandle; QMainWindow_setCentralWidget(QMainWindowH(Result), MDIAreaHandle); QMainWindow_setDockOptions(QMainWindowH(Result), QMainWindowAnimatedDocks); This no: CentralWidget := QWidget_create(Result); QMainWindow_setCentralWidget(QMainWindowH(Result), CentralWidget); If you know fast solution, please commit, or I will start my investigation.

That's the reason why I set IFDEF MDIDEVEL there (removed with IFDEF QT_4_3) . It can be workarounded but, there must be a better solution. QMdiArea should be central widget when we have an MDI application, setting dummy widget as central widget is a bad idea, since in that case we'll never have functional MDI application.

zeljko

Paul Ishenin
to zeljko
zeljko wrote 20 lines
On Monday 09 July 2007 09:50, Paul Ishenin wrote: > This code cause overlaying MenuBar by other controls: > > MDIAreaHandle := QMdiArea_create(Result); > CentralWidget := MDIAreaHandle; > QMainWindow_setCentralWidget(QMainWindowH(Result), MDIAreaHandle); > QMainWindow_setDockOptions(QMainWindowH(Result), QMainWindowAnimatedDocks); > > This no: > > CentralWidget := QWidget_create(Result); > QMainWindow_setCentralWidget(QMainWindowH(Result), CentralWidget); > > If you know fast solution, please commit, or I will start my investigation. That's the reason why I set IFDEF MDIDEVEL there (removed with IFDEF QT_4_3) . It can be workarounded but, there must be a better solution. QMdiArea should be central widget when we have an MDI application, setting dummy widget as central widget is a bad idea, since in that case we'll never have functional MDI application.

Please create a patch where you locate all MDI stuff in QtMDI or other ifdef.

Best regards,
Paul Ishenin.

Felipe Monteiro de Carvalho
to Paul Ishenin
Paul Ishenin wrote
Please create a patch where you locate all MDI stuff in QtMDI or other ifdef.

I would prefer to fix MDI instead.

In the mean time don't define USE_QT_4_3 when compiling the IDE.

You can use the binary bindings for 4.3 and Qt 4.3 even if you don't define USE_QT_4_3

Qt is backwards compatible.

thanks,

Felipe Monteiro de Carvalho
Павел Ишенин
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 15 lines
On 7/9/07, Paul Ishenin wrote: > Please create a patch where you locate all MDI stuff in QtMDI or other > ifdef. > I would prefer to fix MDI instead. In the mean time don't define USE_QT_4_3 when compiling the IDE. You can use the binary bindings for 4.3 and Qt 4.3 even if you don't define USE_QT_4_3 Qt is backwards compatible.

Then maybe we can skip Qt prefix in define and call it {$ifdef Lazarus_MDI_Support} for example ;)

MDI suport is cool, but not every application needs it, so not every QMainWidget should contain QMdiArea inside. We can add that area when our MainForm.FormStyle become fsMDIForm and remove it if it is exists in other case. Since Lazarus IDE is not MDI application I will not get this bug while launching IDE.

What do you think?

Best regards,
Paul Ishenin.

zeljko
to Павел Ишенин
????? ?????? wrote 24 lines
Felipe Monteiro de Carvalho wrote: > On 7/9/07, Paul Ishenin wrote: >> Please create a patch where you locate all MDI stuff in QtMDI or other >> ifdef. > > I would prefer to fix MDI instead. > > In the mean time don't define USE_QT_4_3 when compiling the IDE. > > You can use the binary bindings for 4.3 and Qt 4.3 even if you don't > define USE_QT_4_3 > > Qt is backwards compatible. Then maybe we can skip Qt prefix in define and call it {$ifdef Lazarus_MDI_Support} for example ;) MDI suport is cool, but not every application needs it, so not every QMainWidget should contain QMdiArea inside. We can add that area when our MainForm.FormStyle become fsMDIForm and remove it if it is exists in other case. Since Lazarus IDE is not MDI application I will not get this bug while launching IDE. What do you think?

I think that best thing would be to add IFDEF FOO_MDI_OR_CALL_IT_WHATEVER for mdi area creation. I already said to Felipe that it's not good idea to isolate MDI with QT_4_3 ifdef, because it will always create mdi area with qt-4.3. Only those 3 lines are for MDI so pls. add some IFDEF around MDI and things are fixed (I cannot make any patches for next few days). I'm using MDI so don't delete those lines pls ;)

zeljko

Felipe Monteiro de Carvalho
to zeljko: That's the reason why I set IFDEF MDIDEVEL there (removed with IFDEF QT_4_3) . It can be…
zeljko wrote
It can be workarounded but, there must be a better solution. QMdiArea should be central widget when we have an MDI application, setting dummy widget as central widget is a bad idea, since in that case we'll never have functional MDI application.

What about the opposite approach then?

We put a QWidget as central widget normally, and then put a MDIArea inside it.

Felipe Monteiro de Carvalho
zeljko
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 10 lines
On 7/9/07, zeljko wrote: > It can be workarounded but, there must be a better solution. > QMdiArea should be central widget when we have an MDI application, > setting dummy widget as central widget is a bad idea, since in that case > we'll never have functional MDI application. What about the opposite approach then? We put a QWidget as central widget normally, and then put a MDIArea inside it.

hm...really don't know, that depends on qt, qmdiarea is commonly used as central widget of QMainWindow, but can be used also as central widget on any widget, so your idea comes here ;)

Felipe Monteiro de Carvalho
to zeljko
zeljko wrote
hm...really don't know, that depends on qt, qmdiarea is commonly used as central widget of QMainWindow, but can be used also as central widget on any widget, so your idea comes here ;)

I see this as a solution. And we could also only create the qmdiarea if the form is indeed a mdiform.

Felipe Monteiro de Carvalho
Павел Ишенин
to Felipe Monteiro de Carvalho

Felipe Monteiro de Carvalho ?????:

Show quoted text 10 lines
On 7/9/07, zeljko wrote: > hm...really don't know, that depends on qt, qmdiarea is commonly used as > central widget of QMainWindow, but can be used also as central widget on any > widget, so your idea comes here ;) > I see this as a solution. And we could also only create the qmdiarea if the form is indeed a mdiform.

I think if it will be used only when form is mdiform then no other changes is needed since mdi is usually consists of menu, toolbar and mdi area.

Best regards,
Paul Ishenin.

Felipe Monteiro de Carvalho
to Павел Ишенин

By the way, now I get a crash when my app tryes to create a popup menu and read it's handle.

The crash is on the file qtwsmenus.pp here:

class function TQtWSMenuItem.CreateHandle(const AMenuItem: TMenuItem): HMENU;
....
  if (Menu  nil) then
  begin
    // Trigger event
    QAction_triggered_Event(Method) := Menu.SlotTriggered;
    QAction_hook_hook_triggered(QAction_hook_create(Menu.ActionHandle), Method);
  end;

It crashes inside Qt on the call to Menu.ActionHandle

I tryed to debug and find what needs to be fixed, but breakpoint inserting doesn't work on the qtwsmenus.pp file without a good reason (it's working on another qt interface file) on my mac, and when I set VerboseQt define it didn't output anything for this function o.O very wierd. Althougth it seams to have output for the other ones.

Felipe Monteiro de Carvalho
Unknown author
to Felipe Monteiro de Carvalho: I see this as a solution. And we could also only create the qmdiarea if the form is…
I see this as a solution. And we could also only create the qmdiarea

Agree, but my expirience with qt&mdi says that there could be some event based issues (especially repainting things), on the other side, there was a good reason why trolltech go away from QWorkspace to QMdiArea class (4.3). I hope that they polished those things (especially because I've seen code which can disallow new mdi windows to be maximized by default if there's already maximized MDI child ;) ).

if the form is indeed a mdiform.

Of course, that's why I've inserted $ifdef mdidevel with first mdi patch.

Felipe Monteiro de Carvalho
to Unknown author
> if the form is indeed a mdiform. Of course, that's why I've inserted $ifdef mdidevel with first mdi patch.

What I mean is: check the form style. If it is fsMdiForm, then add the mdi area. This check is a run-time check, not an ifdef.

Felipe Monteiro de Carvalho
Paul Ishenin
to Felipe Monteiro de Carvalho

Felipe Monteiro de Carvalho ?????:

Show quoted text 7 lines
On 7/9/07, wrote: >> if the form is indeed a mdiform. > Of course, that's why I've inserted $ifdef mdidevel with first mdi patch. What I mean is: check the form style. If it is fsMdiForm, then add the mdi area. This check is a run-time check, not an ifdef.

Ok, I commited changes with check of FormStyle and removed workaroung with LCLComponent.Tag = 9999. I also removed exception in LCL that prevented creating of MDIxxx forms. Hope now everybody is happy - at least me :)

I also looked at PopupMenu problem. There was one with destroying popupMenu.

And I also found why menubar had been overlayed by other components.

Because of this code in TQtMainWindow.GetContainerWidget:

     if (CentralWidget  nil) and (MDIAreaHandle = nil) then
                                  ^^^^^^^^^^^^^^^^^^^^^^

I also added LayoutWidget to windows that are not QMainWindow. So now IDE menubar shows menu.

Hope you will ide look after commit at same address (only menu is visible and less taskbar items): http://free1c.narod.ru/qt/qt_ide.png

I will continue with fixing qt problems that I have in ide.

Best regards,
Paul Ishenin.