Results 1 to 3 of 3

Thread: yet another sizePolicy prob: how can I get a QTextBrowser to scale with its QTabWidg

  1. #1
    Join Date
    Mar 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default yet another sizePolicy prob: how can I get a QTextBrowser to scale with its QTabWidg

    My mainWindow has a centralWidget with a QTabWidget filling it; I want one of the tab pages to have a stretchable widget filling it as well. I haven't been able to get it to work with QT designer, even when I hand-edit the XML file to ensure I have the structure I want.
    It seems that the solution should be to set the SizePolicy property correctly, but even though I've put either "Ignored" or "Expanding" on each QWidget, and tried setting the horstretch attributes, it won't stretch. I'm using CTRL-R within QTDesigner to check it.
    I see other posts similar to this, but none seem to have any answer. I'm attaching a tiny demo UI file, too.
    Attached Files Attached Files

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: yet another sizePolicy prob: how can I get a QTextBrowser to scale with its QTab

    You need to place widgets in a layout if you want sizing behavior to be honored.

  3. #3
    Join Date
    Mar 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: yet another sizePolicy prob: how can I get a QTextBrowser to scale with its QTab

    that was a good hint - though it's a bit trickier than that. I had already been nesting layout/widget/layout as I built it.
    For others with this problem, here's the 'fix' (Here's a sample UI) too:

    if you look into the first UI file you'll see this:

    <class>MainWindow</class>
    <widget class="QMainWindow" name="MainWindow">
    <widget class="QWidget" name="centralwidget">
    <layout class="QVBoxLayout" name="centralLayout">
    <item>
    <widget class="QTabWidget" name="tabBoyWidget">
    <widget class="QWidget" name="tab_the_first">
    <widget class="QWidget" name="tab1layoutWidg">
    <layout class="QVBoxLayout" name="tabOneLayout">
    <item>
    <widget class="QTextBrowser" name="textBrowser">

    =====================
    the problem is the <widget ...> <widget ...><widget ...> <layout ...><item><widget> - For some reason, QT Designer wants to add an extra layer of QWidget. It has to be removed with a text editor, outside of QTDesigner.
    For example:
    once it's working, and I want to add a page:
    Using QT Designer, right-click and add a page. Put the layout in the new page, and add a widget to it. Save and close.
    Open in a text editor. You'll find a new <widget name="tab"><attribute><widget name = "...layoutWidget"><property><layout....><item>
    Delete the <widget> between the <attribute> and <property> tags (and its </widget>) and re-open in QT Designer. Now it'll respect its sizePolicy.
    Attached Files Attached Files

Similar Threads

  1. QToolbar expanding sizePolicy not working properly
    By sfcheng77 in forum Qt Programming
    Replies: 2
    Last Post: 23rd February 2011, 00:50
  2. QTabWidget Expanding sizepolicy
    By Zweistein in forum Qt Programming
    Replies: 0
    Last Post: 25th October 2010, 15:34
  3. Nested Layouts and sizePolicy
    By pagapov in forum Newbie
    Replies: 13
    Last Post: 24th October 2010, 10:29
  4. layouts, sizePolicy, sizeHint,
    By Kronen in forum Newbie
    Replies: 2
    Last Post: 5th November 2009, 18:43
  5. The use of SizePolicy
    By Placido Currò in forum Newbie
    Replies: 2
    Last Post: 9th April 2009, 23:10

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.