Results 1 to 4 of 4

Thread: How to resize a Button

  1. #1
    Join Date
    Mar 2007
    Location
    Vienna / Austria
    Posts
    54
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default How to resize a Button

    How to resize a QPushButton which is inside of a Layout?

    the command

    Qt Code:
    1. button->setGeometry(p1,p3,w,h);
    To copy to clipboard, switch view to plain text mode 
    has no effect!

    Best Regards?

  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: How to resize a Button

    You are not supposed to resize widgets managed by a layout by hand. It's the layout's responsibility to provide sufficient geometries. There are numerous ways to adjust the behavior. Size hints, size policies, stretch factors and spacers, spacings, margins, nested layouts etc. I'd suggest starting with reading about layout classes and going through the basic examples.

    If in doubt, provide a screenshot of what you've got so far and explain how would you like it to be and we might be able to give hints.
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    viking (27th April 2007)

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to resize a Button

    If you still really need to resize the button, use QWidget::setFixedSize() just be warned that you shouldn't do that if you don't have to. A better (but still not the best) approach is to use QWidget::setMinimumSize() and QWidget::setMaximumSize() to allow some flexibility.

  5. The following user says thank you to wysota for this useful post:

    viking (27th April 2007)

  6. #4
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to resize a Button

    Ok, I got that, but I have dynically located buttons in QGridLayout, which is taking too much place in my app. How do I resize it? Shold I resize every pushbutton added to QGridLayout or resize QGridLayout itself?
    Qt 5.3 Opensource & Creator 3.1.2

Similar Threads

  1. Disable Checkable Button Question
    By jbpvr in forum Qt Programming
    Replies: 9
    Last Post: 20th March 2007, 17:57
  2. Custom Shape Widget (resize)
    By PiXeL16 in forum Qt Programming
    Replies: 7
    Last Post: 12th February 2007, 07:00
  3. Mouse Over event on button
    By vishal.chauhan in forum Qt Programming
    Replies: 9
    Last Post: 10th January 2007, 05:03
  4. postponing resize event
    By Honestmath in forum Qt Programming
    Replies: 11
    Last Post: 26th February 2006, 00:32
  5. Push button double click
    By curtisw in forum Qt Programming
    Replies: 3
    Last Post: 15th February 2006, 16:40

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.