not so handsome window behavior

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
midgetfc
Posts: 60
Joined: Fri May 15, 2009 2:50 pm

not so handsome window behavior

Post by midgetfc »

Hello,
when I open a file straight after starting FreeCAD, a ghost from the Start page browser window stays on the screen like in the sceen capture below:
Capture.jpg
Capture.jpg (49.46 KiB) Viewed 4486 times
I don't know if it is specific to Linux/X11, or if it is a misbehaviour of (the old) QWorkspace.
It is a very minor problem, but could give a bad feeling to newcomers.
As a crude hack to correct this, it is possible to add those two lines at the end of the function void MainWindow::addWindow(MDIView* view) (file Gui/MainWindow.cpp):

Code: Select all

    d->workspace->activatePreviousWindow();
    d->workspace->activateNextWindow();
to toggle windows and force a refresh each time a new MDIView is inserted.
Keep on the good work on FreeCAD.
Cheers
wmayer
Founder
Posts: 20307
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: not so handsome window behavior

Post by wmayer »

Hi,

yes this is an issue on all platforms. Maybe it is an issue with QWorkspace -- I have to check if QMdiArea solves that. Thanks for this hint.
The point is if the start page is shown after startup there is somehow an update problem with other MDI views afterwards but only for the next one. All further MDI views seem to work then.

For the time being I think the best is to completely switch off the start page. You'll find it under Preferences>General>Online help>Show start page.

Cheers,
Werner
midgetfc
Posts: 60
Joined: Fri May 15, 2009 2:50 pm

Re: not so handsome window behavior

Post by midgetfc »

Hello,
I've tried to use a QMdiArea instead of a QWorkspace to have a clean workaround instead of a crude hack.
Unfortunately, it is no a direct drop in replacement because QMdiArea uses QMdiSubWindows instead of QWidgets and more of a problem, I couldn't figure how to access QMdiArea built-in Tab functionality to attach the custom context menu. Maybe the hack could do for now. Let me know if you want me to dig this a little further...
Cheers
wmayer
Founder
Posts: 20307
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: not so handsome window behavior

Post by wmayer »

I have tried out the new QMdiArea and in fact this fixes the update problem and also another issue I have seen for a long time. However, I have to do a proper migration from QWorspace to QMdiArea as it seems to cause some minor problems. For instance there is no title bar for a 3d sub-window.
wmayer
Founder
Posts: 20307
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: not so handsome window behavior

Post by wmayer »

Hi midgetfc

In the latest SVN sources I have integrated the new QMdiArea as replacement for QWorkspace -- by using a #define which is off by default. You'll find everything you need in MainWindow.cpp and MainWindow.h. In MainWindow.h you can uncomment #define USE_QT_MDI_AREA to make it working.

So far, it solves the update problem but introduces more strange problems. For any reason the window activation stuff doesn't work as it should. However, from the Qt sources I have found an MDI example which works as it should, so it's probably not a Qt bug.

If you like you can have a look on that issue.

Cheers,
Werner
midgetfc
Posts: 60
Joined: Fri May 15, 2009 2:50 pm

Re: not so handsome window behavior

Post by midgetfc »

I'll do. Thanks a lot.
But as I'm more of the "slow type", just expect some news in a few weeks ;)
Cheers
wmayer
Founder
Posts: 20307
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: not so handsome window behavior

Post by wmayer »

No, problem! For the moment I have applied your trick to temp. switch to another MDI view and then switch back to the new MDI again. So far this seems to work OK.
Anyway, in the future I think we should still switch to QMdiArea but this is not urgent.
wmayer
Founder
Posts: 20307
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: not so handsome window behavior

Post by wmayer »

OK, I solved the problem. The MDi child view didn't like the way how we embedded the OpenGL canvas. So, now I have set the new QMdiArea as the default and it works pretty nice, so far.
midgetfc
Posts: 60
Joined: Fri May 15, 2009 2:50 pm

Re: not so handsome window behavior

Post by midgetfc »

Impressive rework!
Evrything seems to be OK with the windows now.
I didn't knew the accepted way to access MdiArea private embedded TabBar, and was afraid to resort to d-pointers or some other Qt internal stuff.
I suppose you still need to guess there is one (or look at the sources) as, although blatant, it is not publicly documented in the API ?
Still a long way to go for me.

midgetfc
wmayer
Founder
Posts: 20307
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: not so handsome window behavior

Post by wmayer »

I didn't knew the accepted way to access MdiArea private embedded TabBar, and was afraid to resort to d-pointers or some other Qt internal stuff.
The trick is fairly simple. All what you need to know is that the tab bar is a child of the QMdiArea and you can easily access it with the findChild() template method. You don't access the internal d-pointers for that.

There is also a way to directly access d-pointers for most of the Qt classes, e.g. for QMdiArea there is a private header file qmdiarea_p.h where you get the d-pointer with QObjectPrivate::get(). However, you shouldn't make too much usage of it because the private classes may change for newer Qt versions, for Windows you have the limitation that not all symbols are exported and thus cause linker errors and on many Linux distributions these private headers are not installed at all.
Post Reply