Results 1 to 2 of 2

Thread: making tab width size smaller

  1. #1
    Join Date
    Nov 2015
    Posts
    128
    Thanks
    70
    Qt products
    Qt5
    Platforms
    Windows

    Default making tab width size smaller

    hi,
    i have wrote under code. while clicking on button4 (ok) 2 editlines will be invisiable. when those. are invisiable, i need tab be smaller and fit to the pushbuttons instead of pushbuttons be larger. thanks for any help



    Qt Code:
    1. #include "mainwindow.h"
    2.  
    3. #include <QApplication>
    4. #include <QWidget>
    5. #include <QLineEdit>
    6. #include <QCheckBox>
    7. #include <QTabWidget>
    8. #include <QPushButton>
    9. #include <QGridLayout>
    10.  
    11.  
    12. int main(int argc, char *argv[])
    13. {
    14. QApplication a(argc, argv);
    15. //MainWindow w;
    16. //w.show();
    17. QWidget qwd;
    18. QWidget t1;
    19. QTabWidget tab(&qwd);
    20. tab.addTab(&t1,"tab");
    21.  
    22. QGridLayout gl_tab(&t1);
    23. QGridLayout gl_qwd(&qwd);
    24.  
    25. QPushButton p1(&t1);
    26. QPushButton p2(&t1);
    27. QLineEdit l1(&t1);
    28. QLineEdit l2(&t1);
    29. gl_tab.addWidget(&l1,0,0);
    30. gl_tab.addWidget(&l2,1,0);
    31. gl_tab.addWidget(&p1,0,1);
    32. gl_tab.addWidget(&p2,1,1);
    33. l1.setVisible(1);
    34. l2.setVisible(1);
    35.  
    36.  
    37. QPushButton p3(&qwd);
    38.  
    39. QPushButton p4(&qwd);
    40. p4.setText("ok");
    41.  
    42. QPushButton p5(&qwd);
    43.  
    44. gl_qwd.addWidget(&tab,0,0,1,1);
    45. gl_qwd.addWidget(&p3,0,1,1,1);
    46. gl_qwd.addWidget(&p4,1,0,1,1);
    47. gl_qwd.addWidget(&p5,1,1,1,1);
    48.  
    49. QObject::connect(&p4, SIGNAL(clicked(bool)), &l1, SLOT(setVisible(bool)));
    50. QObject::connect(&p4, SIGNAL(clicked(bool)), &l2, SLOT(setVisible(bool)));
    51.  
    52. qwd.show();
    53. return a.exec();
    54. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: making tab width size smaller

    You can try resizing the widget to its sizeHint() or even resizing to 0,0 and let the layout expand it again as necessary.

    Cheers,
    _

Similar Threads

  1. Replies: 8
    Last Post: 22nd March 2016, 04:39
  2. Smaller dlls size.
    By menel in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 5th July 2010, 10:37
  3. QVBoxLayout width size limit
    By QPlace in forum Qt Programming
    Replies: 7
    Last Post: 18th June 2009, 16:41
  4. Can QHash::capacity() be smaller than QHash::size()?!?
    By iw2nhl in forum Qt Programming
    Replies: 2
    Last Post: 24th August 2007, 01:17
  5. How can I make size of QGraphicsScene smaller?
    By troorl_ua in forum Qt Programming
    Replies: 6
    Last Post: 21st April 2007, 07:56

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.