Results 1 to 3 of 3

Thread: Resize button with window and layout

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

    Default Resize button with window and layout

    I have Grid layout within that I have scrollArea where I am creating dynamic buttons, layout is within the centralWidget , When I resize (shrink , expand ) i want to resize my layout as well as button inside that .
    How can I do that
    I have tried adjustSize and setSizePolicy fixed and expanding but nothing works on layout
    when I shrink the window button are hidden in stand of it I want it to be shrink with window size

  2. #2
    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.

  3. #3
    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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.