Results 1 to 8 of 8

Thread: resizing events of a custom widget in a layout

  1. #1
    Join Date
    Feb 2008
    Posts
    25
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default resizing events of a custom widget in a layout

    I have created a custom widget that has things different graphs that are placed on it by a QPainter. (Not sure if this info is needed or not). When I start the program everything comes up fine, but when I change the size of the window the custom widget just stays the same size and everything around it is distorted.

    The custom widget is in a vertical layout and the custom widget is a public QWidget.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: resizing events of a custom widget in a layout

    Use layouts.
    J-P Nurmi

  3. #3
    Join Date
    Feb 2008
    Posts
    25
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: resizing events of a custom widget in a layout

    Quote Originally Posted by jpn View Post
    Use layouts.
    Yeah,

    I am using layouts. That is why I am having issues and don't know what to do. Is there a flag that I have to set or something. Again the issue is when I resize the window my custom widget stays the same size.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: resizing events of a custom widget in a layout

    Sounds like you're missing the top level layout. Even if child widgets are laid into a layout no layout might be installed on the window itself.
    J-P Nurmi

  5. #5
    Join Date
    Feb 2008
    Posts
    25
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: resizing events of a custom widget in a layout

    Quote Originally Posted by jpn View Post
    Sounds like you're missing the top level layout. Even if child widgets are laid into a layout no layout might be installed on the window itself.
    I now have a top level layout and I am still having problems. The custom QPainter widget that I have created is a QWidget. The other custom Widget that I am add it to is a QMainWindow. Could this be a problem? If I change t to a QFrame do you think I will work better.

    This is the first time I have had to do something like this and am really getting frustrated at it.

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: resizing events of a custom widget in a layout

    Quote Originally Posted by Rooster View Post
    The custom QPainter widget that I have created is a QWidget.
    What? QPainter is a QWidget? How come? I'm confused. Usually you create a QPainter on a paint device (eg. QWidget) to paint on it...
    J-P Nurmi

  7. #7
    Join Date
    Feb 2008
    Posts
    25
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: resizing events of a custom widget in a layout

    Ok, never mind that.

    Right now when I run the program I get the error

    QLayout "unnamed" added to protein "unnamed", which already has a layout

    is there a reason that this is happening.

  8. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: resizing events of a custom widget in a layout

    Quote Originally Posted by Rooster View Post
    Right now when I run the program I get the error

    QLayout "unnamed" added to protein "unnamed", which already has a layout

    is there a reason that this is happening.
    In Qt 3 layouts are installed by passing the parent widget to QLayout constructor. Most likely you pass same widget by accident to two different layouts. Thus, the latter attempt gives you a warning because you can't install two layouts on same widget.
    J-P Nurmi

Similar Threads

  1. changing layout of a widget
    By mikro in forum Qt Programming
    Replies: 10
    Last Post: 4th August 2009, 20:21
  2. Custom widget
    By zorro68 in forum Qt Programming
    Replies: 7
    Last Post: 28th January 2008, 14:06
  3. custom plug-in widget in another custom plug-in widget.
    By MrGarbage in forum Qt Programming
    Replies: 6
    Last Post: 27th August 2007, 15:38
  4. Problem with custom container widget
    By MrGarbage in forum Qt Tools
    Replies: 4
    Last Post: 25th August 2007, 03:37
  5. Custom tab widget question
    By PrimeCP in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2007, 11:17

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.