Re: [Interest] Qt5: Obtain current layout size
Den 23-07-2012 15:41, Stephen Chu skrev: On 7/23/12 4:52 AM, Bo Thorsen wrote: Den 22-07-2012 21:49, Stephen Chu skrev: On 7/22/12 6:30 AM, Bo Thorsen wrote: Den 21-07-2012 18:27, Stephen Chu skrev: I am working on a dynamically generated form. One thing I'd like to do is to reflow the layout into multi-column when the widgets fill the preset window height. I need to find out what the current layout height is before I add the new widget. The problem is, layout geometry is always 0x0 before the window is shown. And if I show the window before adding the widgets, not only does the window flickers badly, it also doesn't auto-position correctly. What's worse, the geometry reported is still 0x0. So how do I get the correct layout or parent widget size before showing the widget/window? Thanks. You can't use size or geometry because they are properties of what is actually shown. For your case, you should use the minimum sizes instead. Those should be available to you. Thanks. That works. Do you happen to know how I can get the size of a window maximized without first maximize it? You can't do that. The real fix for what you are trying to do here is to write your own layout manager class. You should subclass QLayout and implement the layouting yourself. It's the only way (I think) that truly does what you want to achieve without using a bunch of bad hacks along the way. I wouldn't say it's a hack. I am arranging the layout dynamically by considering how much the window is allowed to grow. What you're trying to do isn't a hack, of course. What you end up having to do to implement it will be. Your problem with the full screen shows this. And even if I go custom layout route, I still need to know where I need to place the new widget so I don't grow the window out of the screen, right? The layout manager is asked the minimum size of the widget, which for you is impossible to answer. This is already an indication why you have problems here. In case you want to discuss if this is possible or not: minimumSize gives a QSize back. In your case, the minimum height is actually the height of one row. But for any number of rows, the minimum width changes. There is, however, a function called heightForWidth or widthForHeight - I don't remember which way they chose. This might actually be exactly what you are looking for. Try experimenting with that. Anyway, once the size of the window is chosen, the layout manager is asked to place the widgets inside the parent. At this point, the layout knows what size the container will have, so it can place the widgets correctly. Bo Thorsen, Fionia Software. -- Expert Qt and C++ developer for hire Contact me if you need expert Qt help http://www.fioniasoftware.dk ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Qt5: Obtain current layout size
Am Sun, 22 Jul 2012 15:49:13 -0400 schrieb Stephen Chu step...@ju-ju.com: Thanks. That works. Do you happen to know how I can get the size of a window maximized without first maximize it? what about: http://qt-project.org/doc/qt-4.8/qapplication.html#desktop alex -- /* * Never be bullied into silence. Never allow yourself to * be made a victim. Accept no one's definition of your * life; define yourself.--Harvey Fierstein * */ signature.asc Description: PGP signature ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Qt5: Obtain current layout size
Den 22-07-2012 21:49, Stephen Chu skrev: On 7/22/12 6:30 AM, Bo Thorsen wrote: Den 21-07-2012 18:27, Stephen Chu skrev: I am working on a dynamically generated form. One thing I'd like to do is to reflow the layout into multi-column when the widgets fill the preset window height. I need to find out what the current layout height is before I add the new widget. The problem is, layout geometry is always 0x0 before the window is shown. And if I show the window before adding the widgets, not only does the window flickers badly, it also doesn't auto-position correctly. What's worse, the geometry reported is still 0x0. So how do I get the correct layout or parent widget size before showing the widget/window? Thanks. You can't use size or geometry because they are properties of what is actually shown. For your case, you should use the minimum sizes instead. Those should be available to you. Thanks. That works. Do you happen to know how I can get the size of a window maximized without first maximize it? You can't do that. The real fix for what you are trying to do here is to write your own layout manager class. You should subclass QLayout and implement the layouting yourself. It's the only way (I think) that truly does what you want to achieve without using a bunch of bad hacks along the way. Bo Thorsen, Fionia Software. -- Expert Qt and C++ developer for hire Contact me if you need expert Qt help http://www.fioniasoftware.dk ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Qt5: Obtain current layout size
On 7/23/12 4:52 AM, Bo Thorsen wrote: Den 22-07-2012 21:49, Stephen Chu skrev: On 7/22/12 6:30 AM, Bo Thorsen wrote: Den 21-07-2012 18:27, Stephen Chu skrev: I am working on a dynamically generated form. One thing I'd like to do is to reflow the layout into multi-column when the widgets fill the preset window height. I need to find out what the current layout height is before I add the new widget. The problem is, layout geometry is always 0x0 before the window is shown. And if I show the window before adding the widgets, not only does the window flickers badly, it also doesn't auto-position correctly. What's worse, the geometry reported is still 0x0. So how do I get the correct layout or parent widget size before showing the widget/window? Thanks. You can't use size or geometry because they are properties of what is actually shown. For your case, you should use the minimum sizes instead. Those should be available to you. Thanks. That works. Do you happen to know how I can get the size of a window maximized without first maximize it? You can't do that. The real fix for what you are trying to do here is to write your own layout manager class. You should subclass QLayout and implement the layouting yourself. It's the only way (I think) that truly does what you want to achieve without using a bunch of bad hacks along the way. I wouldn't say it's a hack. I am arranging the layout dynamically by considering how much the window is allowed to grow. And even if I go custom layout route, I still need to know where I need to place the new widget so I don't grow the window out of the screen, right? I think I will dig into the source to see if existing QLayouts does anything for that. Thanks for the help. ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Qt5: Obtain current layout size
On 7/23/12 2:04 AM, alexander golks wrote: Am Sun, 22 Jul 2012 15:49:13 -0400 schrieb Stephen Chu step...@ju-ju.com: Thanks. That works. Do you happen to know how I can get the size of a window maximized without first maximize it? what about: http://qt-project.org/doc/qt-4.8/qapplication.html#desktop That's the combined desktop. I don't want to grow the window across screens. :) But that's a good starting point to look. Thanks for the pointer. ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Qt5: Obtain current layout size
Den 21-07-2012 18:27, Stephen Chu skrev: I am working on a dynamically generated form. One thing I'd like to do is to reflow the layout into multi-column when the widgets fill the preset window height. I need to find out what the current layout height is before I add the new widget. The problem is, layout geometry is always 0x0 before the window is shown. And if I show the window before adding the widgets, not only does the window flickers badly, it also doesn't auto-position correctly. What's worse, the geometry reported is still 0x0. So how do I get the correct layout or parent widget size before showing the widget/window? Thanks. You can't use size or geometry because they are properties of what is actually shown. For your case, you should use the minimum sizes instead. Those should be available to you. Bo Thorsen, Fionia Software. -- Expert Qt and C++ developer for hire Contact me if you need expert Qt help http://www.fioniasoftware.dk ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Qt5: Obtain current layout size
On 7/22/12 6:30 AM, Bo Thorsen wrote: Den 21-07-2012 18:27, Stephen Chu skrev: I am working on a dynamically generated form. One thing I'd like to do is to reflow the layout into multi-column when the widgets fill the preset window height. I need to find out what the current layout height is before I add the new widget. The problem is, layout geometry is always 0x0 before the window is shown. And if I show the window before adding the widgets, not only does the window flickers badly, it also doesn't auto-position correctly. What's worse, the geometry reported is still 0x0. So how do I get the correct layout or parent widget size before showing the widget/window? Thanks. You can't use size or geometry because they are properties of what is actually shown. For your case, you should use the minimum sizes instead. Those should be available to you. Thanks. That works. Do you happen to know how I can get the size of a window maximized without first maximize it? Thanks. ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Qt5: Obtain current layout size
On 07/21/2012 12:27 PM, Stephen Chu wrote: I am working on a dynamically generated form. One thing I'd like to do is to reflow the layout into multi-column when the widgets fill the preset window height. Hack alert... Some Window Managers will let you bring a window up off screen where it will exhibit the final size, but not appear to the user. In the past I have used this trick to find the final size of a window before I move it into view. Bill I need to find out what the current layout height is before I add the new widget. The problem is, layout geometry is always 0x0 before the window is shown. And if I show the window before adding the widgets, not only does the window flickers badly, it also doesn't auto-position correctly. What's worse, the geometry reported is still 0x0. So how do I get the correct layout or parent widget size before showing the widget/window? Thanks. ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
[Interest] Qt5: Obtain current layout size
I am working on a dynamically generated form. One thing I'd like to do is to reflow the layout into multi-column when the widgets fill the preset window height. I need to find out what the current layout height is before I add the new widget. The problem is, layout geometry is always 0x0 before the window is shown. And if I show the window before adding the widgets, not only does the window flickers badly, it also doesn't auto-position correctly. What's worse, the geometry reported is still 0x0. So how do I get the correct layout or parent widget size before showing the widget/window? Thanks. ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest