Results 1 to 4 of 4

Thread: layout to fill all free space (vertical and horizontal)

  1. #1
    Join Date
    Jun 2019
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default layout to fill all free space (vertical and horizontal)

    I've stripped my problem to this simple case.
    The main window has a vertical layout. A text edit is in that layout. At run time the text edit should adjust it's size to the width and height of the window.
    The text edit adjusts it's width according to the form, but it's height does not.
    I've changed the layout to a grid layout and I've tried all kinds of size policies, but the height of the text edit does not change if I change at run time the height of the window.

    What I really want is a window with a tab widget at the bottom that adjusts it's width to the form. But the height of the tab widget should stay 100px, independent of the size of the window.
    Above the tab widget is a plain text edit that fills all the free space on the form. And of course the user must be able to adjust the size of the window.
    Is it possible to do this in qt creator?

    Kees

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: layout to fill all free space (vertical and horizontal)

    This should be the standard behavior of QTextEdit in a layout so there is likely something interfering or missing.

    How did you create the layout? In code or with QtDesigner?
    What is the base class of your window? QWidget, QMainWindow or something else?

    Cheers,
    _

  3. #3
    Join Date
    Jun 2019
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: layout to fill all free space (vertical and horizontal)

    Quote Originally Posted by anda_skoa View Post
    This should be the standard behavior of QTextEdit in a layout so there is likely something interfering or missing.

    How did you create the layout? In code or with QtDesigner?
    What is the base class of your window? QWidget, QMainWindow or something else?

    Cheers,
    _
    Thank's for your answer.

    It is a bit embarrissing.....

    This is what I've tried in a new project:
    I work only in QT creator
    Starting with a new Widget Application,
    I chose the kit Desktop Qt 5.12.1 MSVC 2017 64 bits
    The main window inherits from QMainWindow
    I open mainwindow.ui in the designer, drag a Text Edit and drop it on the window
    then I right click on the window and chose layout, layout vertically
    Now everything works as expected. Horizontal and vertical scaling works fine.

    Then I removed everything from the window in my old project, removed the layout (right click, remove layout). Then I did exactly the same as in the new project. And the text edit failed to scale vertically.

    The project is not very big yet. So I'll start again with the new project, still wondering what I did wrong.

    Thanks
    Kees

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: layout to fill all free space (vertical and horizontal)

    Try creating a plain QWidget as the central widget of the QMainWindow, adding your layout to that QWidget, and then adding your QTextEdit to that layout.

    I don't usually create QMainWindow layouts in Qt Designer because my central widgets are usually complex - I do it in code in the QMainWindow constructor instead. But it could be that by default Qt Designer inserts a plain QWidget as the central widget, so just add the layout and text edit to that instead.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. How to fill a QFrame space in QSplitter layout
    By henryjoye in forum Qt Programming
    Replies: 2
    Last Post: 12th October 2010, 06:18
  2. Vertical and horizontal QDockWidget, priority?
    By Teuniz in forum Qt Programming
    Replies: 1
    Last Post: 14th June 2010, 11:25
  3. How to get vertical/horizontal zoom box?
    By knicewar in forum Qwt
    Replies: 3
    Last Post: 23rd March 2010, 05:09
  4. Replies: 2
    Last Post: 28th December 2006, 13:38
  5. how to find the free space on a drive
    By klaus1111 in forum Qt Programming
    Replies: 2
    Last Post: 14th July 2006, 11:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.