Results 1 to 5 of 5

Thread: Button in Layout help

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2007
    Posts
    13
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Button in Layout help

    Hi,

    I'am having a problem in my code. I used addSpacing() and SeFixedSized(), to fix the buttons in my code. But the problem is once i enlarge the window, the buttons stay the same size and they dont get bigger with the same ratio as the window. I would appreciate any assistance on how i can fix this problem.

    This is my code:

    Qt Code:
    1. #include <QLabel>
    2. #include <QPushButton>
    3. #include <QProgressBar>
    4. #include <QLineEdit>
    5. #include <QIcon>
    6. #include <QHBoxLayout>
    7. #include <QVBoxLayout>
    8. #include <QToolButton>
    9. #include <QApplication>
    10. #include "auto.h"
    11.  
    12. Auto::Auto(QWidget *parent) : QWidget(parent)
    13. {
    14. // Title of the window
    15. this->setWindowTitle("Main Menu");
    16. this->resize(500, 350); // I'm using your old values
    17.  
    18. b_start = new QPushButton(tr("START/STOP"));
    19. b_exit = new QPushButton(tr("Exit"));
    20.  
    21.  
    22. b_start->setFixedSize(70,30);
    23. b_exit->setFixedSize(50,30);
    24.  
    25. l_welcome = new QLabel(tr("--Automatic Interface--"));
    26. l_welcome->setFont(QFont("Times", 18, QFont::Bold));
    27.  
    28.  
    29. l_welcome->setAlignment(Qt::AlignCenter);
    30.  
    31. l_load = new QLabel(tr("Load Images"));
    32. l_load->setFont(QFont("Times", 12, QFont::Bold));
    33.  
    34. l_load->setAlignment(Qt::AlignLeft);
    35.  
    36. t_text = new QLineEdit(this);
    37. t_text->setFixedSize(150,20);
    38. t_browse = new QToolButton(this);
    39. p_prog = new QProgressBar(this);
    40. p_prog->setFixedSize(100,20);
    41. v_1->setAlignment(Qt::AlignLeft);
    42.  
    43. v_1->addWidget(l_load);
    44. v_1->addSpacing(10);
    45. v_1->addWidget(t_text);
    46. v_1->addWidget(t_browse);
    47. v_1->addSpacing(20);
    48. v_1->addWidget(p_prog);
    49.  
    50. v_2->setAlignment(Qt::AlignCenter);
    51.  
    52. v_2->addWidget(b_start);
    53. v_2->addWidget(b_exit);
    54.  
    55. QVBoxLayout *layout_vert = new QVBoxLayout;
    56. layout_vert->setAlignment(Qt::AlignCenter);
    57.  
    58. layout_vert->addWidget(l_welcome);
    59. layout_vert->addSpacing(30);
    60. layout_vert->addLayout(v_1);
    61. layout_vert->addSpacing(30);
    62. layout_vert->addLayout(v_2);
    63.  
    64.  
    65. this->setLayout(layout_vert);
    66.  
    67. }
    To copy to clipboard, switch view to plain text mode 

    Thanks!!
    Last edited by IsleWitch; 9th October 2007 at 13:57.

Similar Threads

  1. changing layout of a widget
    By mikro in forum Qt Programming
    Replies: 10
    Last Post: 4th August 2009, 20:21
  2. Qt layout memory issue
    By bunjee in forum Qt Programming
    Replies: 9
    Last Post: 25th August 2007, 17:11
  3. problem with Tool button n Layout
    By arjunasd in forum Qt Tools
    Replies: 11
    Last Post: 24th July 2007, 21:14
  4. Resizing problems when applying a layout
    By JimBrown in forum Newbie
    Replies: 1
    Last Post: 21st February 2007, 22:54
  5. Layout issues
    By vijay anandh in forum Qt Programming
    Replies: 2
    Last Post: 8th July 2006, 19:27

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.