Results 1 to 4 of 4

Thread: size of QPushButton

  1. #1
    Join Date
    Nov 2006
    Posts
    96

    Default size of QPushButton

    Hi...

    currently I'm using this code:

    Qt Code:
    1. /* images - on buttons */
    2. close_icon = QIcon(":/close_image");
    3. send_icon = QIcon(":/send_image");
    4. ok_icon = QIcon(":/ok_image");
    5. notok_icon = QIcon(":/notok_image");
    6.  
    7. /* buttons */
    8. send_button = new QPushButton(send_icon, "Send");
    9. send_button->setDisabled(true);
    10. quit_button = new QPushButton(close_icon, "Quit");
    11. attach_button = new QPushButton(ok_icon, "Attach more files");
    12. validate_button = new QPushButton(ok_icon, "Validate");
    13.  
    14. /* buttons layout */
    15. button_layout = new QHBoxLayout();
    16. button_layout->addWidget(send_button);
    17. button_layout->addWidget(quit_button);
    18.  
    19. /* validate layout */
    20. validate_layout = new QHBoxLayout();
    21. validate_layout->addWidget(attach_button);
    22. validate_layout->addWidget(validate_button);
    To copy to clipboard, switch view to plain text mode 

    but if I resize the widget, the buttons are not resized with the widget (layout)... I want to resize buttons with application...so that they consume the whole space that is available.

    Any ideas how to do that...thank you!

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: size of QPushButton

    You must add validate_layout and button_layout to the Widget's Layout
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Nov 2006
    Posts
    96

    Default Re: size of QPushButton

    That's what I did:

    Qt Code:
    1. /* main layout */
    2. QVBoxLayout *main_layout = new QVBoxLayout();
    3. main_layout->addLayout(validate_layout);
    4. main_layout->addLayout(button_layout);
    5. this->setLayout(main_layout);
    To copy to clipboard, switch view to plain text mode 

    but the buttons are not as big as there is space available...they are normal small buttons. I'm sure there are some settings, just don't know which...any other ideas?

  4. #4
    Join Date
    Nov 2006
    Posts
    96

    Default Re: size of QPushButton

    Ah, I got it:

    Qt Code:
    1. setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Qpushbutton
    By iamhere in forum Qt Programming
    Replies: 5
    Last Post: 15th October 2008, 04:40
  2. How to find best size for QTableWidget?
    By plamkata in forum Qt Programming
    Replies: 3
    Last Post: 24th July 2008, 19:07
  3. QPixmap in QPushButton size problem
    By MarkoSan in forum Qt Programming
    Replies: 3
    Last Post: 22nd January 2008, 12:50
  4. QLabel size policy
    By Caius Aérobus in forum Qt Programming
    Replies: 3
    Last Post: 7th December 2007, 17:57
  5. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 22:14

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.