Project

General

Profile

Resizable (Splitter) Layout not working correctly in conjunction with DeferredWidget

Added by Stefan Bn over 1 year ago

I have WContainerWidget with a resizable Layout inside a stacked widget that is triggered by a WMenu.
The sample main.cpp attached demonstrates the problem - equally in Firefox, Edge and IE / Wt 4.8.2.

Non-deferred creation works fine and the resizable layout takes the entire browser area as expected (width:100%, height:100%):

menu->addItem("Split Test", createSplitView());

However, if I defer the creation of this WContainerWidget using the DeferredWidget, the resizable layout does not fill to the entire browser area:

menu->addItem("Split Text", deferCreate(std::bind(&createSplitView)));

Is this expected behavior or some sort of bug because the size-caluclation for the resizable layout is delayed? Is there a workaround for this?

I'd like to create my component only if the user selects the particular MenuItem. Altough menu->addItem has a LazyLoading policy by default, the component gets created immediatly upon application start when not using the DeferredWidget - why is this so?

Thanks,
Stefan

main.cpp (4.96 KB) main.cpp

Replies (4)

RE: Resizable (Splitter) Layout not working correctly in conjunction with DeferredWidget - Added by lm at over 1 year ago

Your code doesn't compile.

I would guess that you need to call the parent's ::Layout or something after you call addWidget? This will tell the parent to reconsider the layout of children.

RE: Resizable (Splitter) Layout not working correctly in conjunction with DeferredWidget - Added by Stefan Bn over 1 year ago

Thanks for seeing into this!

I just checked the code-attachment. It compiles fine without any errors or warnings using Clang. What compiler do you use and what error messages do you get?

I would guess that you need to call the parent's ::Layout or something after you call addWidget?

I'm not sure what you mean by that. Could you give a concrete example please?

"Call ::Layout" is usually a method that returns the corresponding WLayout, not a method to repaint, refresh or recreate a Layout. I tried WApplication::instance()->refresh() after the WStackWidget page was called, but the issue remains.

RE: Resizable (Splitter) Layout not working correctly in conjunction with DeferredWidget - Added by lm at over 1 year ago

When I compile your example, I get

main.cpp: In function ‘int main(int, char**)’:
main.cpp:149:42: error: ‘environ’ was not declared in this scope; did you mean ‘union’?
  149 |             WServer::restart(argc, argv, environ);
      |                                          ^~~~~~~
      |                                          union

I'm not sure how you could possibly compile this successfully; where is environ declared.

Sorry, I was shooting from the hip with the suggestion to ::Layout.

Could you give a concrete example please?

Not at this time. Correct your main.cpp and I'll be happy to see what I can do with it.

RE: Resizable (Splitter) Layout not working correctly in conjunction with DeferredWidget - Added by Stefan Bn over 1 year ago

It's funny, I've never put much attention to the environ variable.

In MinGW/Clang/GNU-compilers this variable is defined in stdlib.h . In many of the Wt code snippets arround this forum here, it's defined as:

#ifndef WT_WIN32
    extern char **environ;
#endif // WT_WIN32

Actually, for my small code sample demonstrating the WLayout problem, the entire line WServer::restart(argc, arg, environ) is not needed and can just be commented out.

I've created an updated version of my code-sample main.cpp, see attachment.
Thanks for investigating this!

Stefan

main.cpp (5.18 KB) main.cpp
    (1-4/4)