Results 1 to 4 of 4

Thread: Scroll bars in scroll area not comming in scroll area

  1. #1
    Join Date
    Oct 2011
    Posts
    160
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default Scroll bars in scroll area not comming in scroll area

    i created scroll area using designer and adding line edit in run time, when button clicked….
    But scroll area is not expanding(scroll bars are inactive even though i set scrollbarAlways on)
    please help me…
    here is my complete code..

    mainwindow.h

    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5.  
    6. namespace Ui {
    7. class MainWindow;
    8. }
    9.  
    10. class MainWindow : public QMainWindow
    11. {
    12. Q_OBJECT
    13.  
    14. public:
    15. explicit MainWindow(QWidget *parent = 0);
    16. ~MainWindow();
    17.  
    18. private slots:
    19. void on_pushButton_clicked();
    20.  
    21. private:
    22. Ui::MainWindow *ui;
    23. };
    24.  
    25. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 


    mainwindow.cpp
    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3.  
    4. MainWindow::MainWindow(QWidget *parent) :
    5. QMainWindow(parent),
    6. ui(new Ui::MainWindow)
    7. {
    8. ui->setupUi(this);
    9.  
    10.  
    11.  
    12. }
    13.  
    14. MainWindow::~MainWindow()
    15. {
    16. delete ui;
    17. }
    18.  
    19.  
    20.  
    21. void MainWindow::on_pushButton_clicked()
    22. {
    23.  
    24. ui->gridLayout->addWidget(le);
    25.  
    26.  
    27. ui->scrollArea->setWidgetResizable(true);
    28.  
    29. }
    To copy to clipboard, switch view to plain text mode 


    mainwindow.ui

    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <ui version="4.0">
    3. <class>MainWindow</class>
    4. <widget class="QMainWindow" name="MainWindow">
    5. <property name="geometry">
    6. <rect>
    7. <x>0</x>
    8. <y>0</y>
    9. <width>400</width>
    10. <height>300</height>
    11. </rect>
    12. </property>
    13. <property name="windowTitle">
    14. <string>MainWindow</string>
    15. </property>
    16. <widget class="QWidget" name="centralWidget">
    17. <layout class="QVBoxLayout" name="verticalLayout">
    18. <property name="sizeConstraint">
    19. <enum>QLayout::SetMinAndMaxSize</enum>
    20. </property>
    21. <item>
    22. <widget class="QScrollArea" name="scrollArea">
    23. <property name="widgetResizable">
    24. <bool>true</bool>
    25. </property>
    26. <widget class="QWidget" name="scrollAreaWidgetContents">
    27. <property name="geometry">
    28. <rect>
    29. <x>0</x>
    30. <y>0</y>
    31. <width>380</width>
    32. <height>198</height>
    33. </rect>
    34. </property>
    35. <widget class="QWidget" name="">
    36. <property name="geometry">
    37. <rect>
    38. <x>40</x>
    39. <y>31</y>
    40. <width>216</width>
    41. <height>25</height>
    42. </rect>
    43. </property>
    44. <layout class="QGridLayout" name="gridLayout">
    45. <property name="sizeConstraint">
    46. <enum>QLayout::SetMinAndMaxSize</enum>
    47. </property>
    48. <item row="0" column="0">
    49. <widget class="QPushButton" name="pushButton_2">
    50. <property name="text">
    51. <string>PushButton</string>
    52. </property>
    53. </widget>
    54. </item>
    55. <item row="0" column="1">
    56. <widget class="QLineEdit" name="lineEdit"/>
    57. </item>
    58. </layout>
    59. </widget>
    60. </widget>
    61. </widget>
    62. </item>
    63. <item>
    64. <widget class="QPushButton" name="pushButton">
    65. <property name="text">
    66. <string>PushButton</string>
    67. </property>
    68. </widget>
    69. </item>
    70. </layout>
    71. </widget>
    72. <widget class="QMenuBar" name="menuBar">
    73. <property name="geometry">
    74. <rect>
    75. <x>0</x>
    76. <y>0</y>
    77. <width>400</width>
    78. <height>21</height>
    79. </rect>
    80. </property>
    81. </widget>
    82. <widget class="QToolBar" name="mainToolBar">
    83. <attribute name="toolBarArea">
    84. <enum>TopToolBarArea</enum>
    85. </attribute>
    86. <attribute name="toolBarBreak">
    87. <bool>false</bool>
    88. </attribute>
    89. </widget>
    90. <widget class="QStatusBar" name="statusBar"/>
    91. </widget>
    92. <layoutdefault spacing="6" margin="11"/>
    93. <resources/>
    94. <connections/>
    95. </ui>
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Oct 2011
    Posts
    160
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Scroll bars in scroll area not comming in scroll area

    Please somebody look at this issue....

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,618
    Thanks
    13
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Scroll bars in scroll area not comming in scroll area

    Remove the grid layout. Set the scroll area layout to grid with the starting push button and edit widget in that grid. Set the scrollBarWidgetContents layoutSizeConstraint to setFixedSize. Add new widgets with ui->scrollBarWidgetContents->layout()->addWidget().

    If you want the scroll bars visible at all times then you should set that... it isn't in your example.

  4. The following user says thank you to ChrisW67 for this useful post:

    aurora (4th January 2012)

  5. #4
    Join Date
    Oct 2011
    Posts
    160
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Scroll bars in scroll area not comming in scroll area

    THANK A LOT CHRIS....
    now its working fine.....

Similar Threads

  1. Scroll bars in scroll area not comming
    By aurora in forum Qt Programming
    Replies: 3
    Last Post: 27th December 2011, 19:56
  2. Q Scroll Area that scrolls??
    By hakermania in forum Newbie
    Replies: 6
    Last Post: 24th August 2010, 19:48
  3. Scroll Area problem
    By Lodhart in forum Qt Programming
    Replies: 0
    Last Post: 10th October 2009, 13:03
  4. scroll area like QGraphicsItem
    By Gopala Krishna in forum Qt Programming
    Replies: 1
    Last Post: 7th February 2008, 11:28
  5. abstract scroll area
    By moowy in forum Qt Programming
    Replies: 2
    Last Post: 2nd October 2006, 09:15

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.