Results 1 to 3 of 3

Thread: Resize button with window and layout

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Resize button with window and layout

    In all likelihood you have not applied the layout to the widget (i.e. myCentralWidget->setLayout(myGridLayout) ). Hard to say as we see no code.

  2. #2
    Join Date
    Nov 2015
    Location
    India
    Posts
    16
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Resize button with window and layout

    Qt Code:
    1. QWidget *w = new QWidget(this);
    2. QGridLayout *grid = new QGridLayout();
    3. ui->scrollArea->setWidget(w);
    4. // this->setFixedSize(this->geometry().width(),this->geometry().height());
    5.  
    6.  
    7. QMap<int,QPushButton*> mapp;
    8. for(row=0;row <= 49 ;row++)
    9. {
    10.  
    11. QPushButton *pb = new QPushButton(w);
    12. grid->addWidget(pb, row/4, row%4);
    13. pb->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding);
    14.  
    15. }
    16.  
    17. w->setLayout(grid);
    To copy to clipboard, switch view to plain text mode 

    Here it is

    when I have tried
    centralWidget()->setLayout(grid);
    it ll shrink with window size but it wont fit in to the layout

Similar Threads

  1. Replies: 1
    Last Post: 29th December 2013, 18:06
  2. Replies: 6
    Last Post: 9th November 2011, 04:31
  3. resize window using a button
    By sachinmcajnu in forum Qt Programming
    Replies: 3
    Last Post: 21st April 2011, 13:52
  4. Replies: 0
    Last Post: 18th January 2011, 16:59
  5. Resize button when using layout
    By Macok in forum Qt Tools
    Replies: 3
    Last Post: 26th January 2009, 00:31

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
  •  
Qt is a trademark of The Qt Company.