Results 1 to 3 of 3

Thread: why scrollbar doesn't display in QscrollArea

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2009
    Posts
    4
    Thanks
    1

    Unhappy why scrollbar doesn't display in QscrollArea

    i add Multiple QListwidget to QscrollArea,but the scrollbar doesn't display in QscrollArea, why?


    Qt Code:
    1. #include "mainwindow.h"
    2.  
    3. MainWindow::MainWindow(QWidget *parent)
    4. : QMainWindow(parent)
    5. {
    6. rightLayout = new QVBoxLayout;
    7. QWidget *widget = new QWidget;
    8. widget->setLayout(rightLayout);
    9. widget->setMinimumHeight(100);
    10. widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    11.  
    12. QScrollArea *scroll = new QScrollArea;
    13. scroll->setWidget(widget);
    14. scroll->setWidgetResizable(true);
    15. splitter = new QSplitter;
    16. QPushButton *button = new QPushButton;
    17. button->setText("Add Widget");
    18. button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    19. splitter->addWidget(button);
    20.  
    21. splitter->addWidget(scroll);
    22.  
    23. QObject::connect(button, SIGNAL( clicked() ), this, SLOT(addMyWidget()));
    24.  
    25.  
    26. this->setCentralWidget(splitter);
    27. }
    28. void MainWindow::addMyWidget()
    29. {
    30. QListWidget *listWidget = new QListWidget;
    31. for(int i = 0; i < 4; i++)
    32. {
    33. newItem->setText("aaaaaa");
    34. listWidget->addItem(newItem);
    35. }
    36.  
    37. listWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    38. rightLayout->addWidget(listWidget);
    39. }
    40.  
    41. MainWindow::~MainWindow()
    42. {
    43.  
    44. }
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images
    • File Type: jpg 1.jpg (7.5 KB, 33 views)
    • File Type: jpg 2.jpg (9.6 KB, 28 views)
    Last edited by wysota; 22nd July 2009 at 19:50. Reason: Changed [quote] to [code]

Similar Threads

  1. QScrollarea events transferring to scrollbar
    By babu198649 in forum Qt Programming
    Replies: 15
    Last Post: 6th September 2013, 22:33
  2. Replies: 1
    Last Post: 13th September 2008, 11:00
  3. Display only PNG image on desktop
    By durbrak in forum Qt Programming
    Replies: 32
    Last Post: 15th March 2008, 21:55
  4. GraphicsView/GraphicsScene: scrollbar policy Qt::ScrollBarAsNeeded
    By Pieter from Belgium in forum Qt Programming
    Replies: 4
    Last Post: 21st March 2007, 13:15
  5. QScrollArea display custom QLabel
    By spawnwj in forum Qt Programming
    Replies: 6
    Last Post: 6th December 2006, 03:38

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.