×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    47

    How to put scrollbar in Qmessage box

    Hello all,

    I am developing an application using qt.

    I have a button call ABOUT US.when i click about us it is showing some message.

    But when my message is large the vertical scroll bar is not coming.

    so please tell me how to solve this problem,please provide me some code ,its urgent.

    With regards

    shakti

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to put scrollbar in Qmessage box

    Not a final solution, but just to show an idea:
    Code:
    #include <QtGui>
    
    int main (int argc, char **argv)
    {
        QApplication app( argc, argv );
    
        QString largeText;
        largeText =
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin pretium porta ipsum, vel mollis lacus dictum sed. Quisque tincidunt arcu lectus. Nam mollis imperdiet commodo. Maecenas dapibus nisl vel augue lobortis aliquet. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In molestie laoreet est, ac pellentesque ipsum lacinia et. Sed eget arcu tellus, at varius felis. In at nibh a neque varius dapibus in sit amet quam. Phasellus porttitor, eros a dignissim feugiat, nisl tortor feugiat ipsum, et ultricies sem justo quis nibh. Curabitur diam sapien, pellentesque ac commodo eu, vehicula id turpis. Sed mollis mi id turpis hendrerit ultrices. Integer egestas consequat vehicula. Proin bibendum neque ac leo iaculis a porta quam accumsan. Phasellus nec quam quis dolor facilisis sagittis. Vivamus et dolor sit amet enim sodales sodales ut et sapien. Quisque sed iaculis risus."
    "Duis elit enim, laoreet id convallis vel, tristique vitae dolor. Nunc id orci et enim ullamcorper consequat ac in orci. Sed est quam, sagittis eu tincidunt id, tempus vitae nunc. Pellentesque quis odio elit, ut hendrerit risus. Nullam elementum rhoncus dapibus. Aenean quis quam turpis. Phasellus a purus sapien, id tincidunt enim. Fusce non arcu at ligula malesuada posuere. Sed commodo risus in nisl fringilla ultrices. Nullam auctor risus a felis accumsan eget tincidunt sem luctus. Donec sodales massa eget turpis tempus lacinia. Donec hendrerit erat at turpis euismod ullamcorper."
    "Ut in risus vitae ante dictum condimentum eget a sapien. Donec eu quam a arcu eleifend porttitor. Donec varius felis eu tortor dignissim sed pretium nibh placerat. Praesent facilisis egestas risus vitae feugiat. Duis blandit varius lorem sit amet placerat. Proin venenatis ante pulvinar diam convallis eu consequat tellus rhoncus. Proin gravida, lorem ut congue faucibus, ipsum neque fermentum nulla, non bibendum mauris tellus vel justo. Vestibulum laoreet malesuada dui, quis pulvinar libero tempor vitae. Sed enim ante, sodales at tempus sed, vestibulum egestas elit. Sed non massa quis odio molestie euismod."
    "Curabitur fringilla lacinia purus ut dictum. Nullam ultricies hendrerit dui sed consequat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Praesent suscipit facilisis porta. Quisque euismod sapien sed sapien posuere rutrum. Nullam tincidunt gravida luctus. Pellentesque eget arcu nisi, sit amet fringilla felis. Cras a neque in elit tristique varius. Integer in cursus felis. Curabitur nisi ligula, egestas vel tincidunt in, gravida ac sem. Curabitur dictum, dui quis accumsan iaculis, diam leo hendrerit lacus, in tempor turpis purus vehicula nisi. Fusce nec mauris non mauris gravida elementum in ac ipsum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Duis elit quam, facilisis id volutpat quis, venenatis in eros. Suspendisse viverra dolor eleifend metus porta consectetur sit amet at elit. Sed id pulvinar justo."
    "Nullam sollicitudin mollis odio, eget aliquet quam pretium quis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ut eros justo, at pellentesque dolor. Nunc nibh massa, sodales ac aliquam vel, porta ac felis. Vestibulum id elit sed enim tincidunt molestie et sed leo. Nullam nec velit nisi. Donec gravida hendrerit velit ut sodales. Pellentesque fermentum arcu sed urna vehicula ut pretium risus tempus. Nunc tempor, nisi ac pharetra elementum, tortor nibh condimentum orci, id eleifend eros mauris vitae magna. Morbi pretium ipsum eget mi vestibulum fermentum blandit diam dignissim. Nullam massa felis, aliquam et fermentum vel, mattis ut lacus. Praesent lobortis dignissim elit, at tincidunt dui auctor at. Nulla congue varius porttitor. Proin tellus ante, accumsan eu ultricies in, sagittis a lectus. Curabitur ac odio mauris, at elementum tellus. Ut eget justo non sapien porttitor sodales sed quis sapien. Phasellus consequat egestas tellus, id sodales tellus fermentum ultrices. Quisque ultricies tincidunt dolor, a fringilla metus sagittis pellentesque. Sed adipiscing, elit ac condimentum viverra, lacus risus gravida lorem, sed dignissim enim nunc nec justo.";
    
        QMessageBox box(QMessageBox::Information, "Message Box", largeText, QMessageBox::Close);
        const QObjectList children = box.children();
        QGridLayout *layout = qobject_cast<QGridLayout *>(children.at(0));
        QLayoutItem *item = layout->itemAtPosition(0, 1);
        if (item) {
            QWidget *widget = item->widget();
            if (widget) {
                QSize sz = widget->size();
                qobject_cast<QLabel *>(widget)->setWordWrap(true);
                layout->removeWidget(widget);
                QScrollArea *area = new QScrollArea();
                area->setMinimumHeight(sz.height());
                area->setWidget(widget);
                layout->addWidget(area, 0, 1);
            }
        }
    
        box.exec();
    }

Similar Threads

  1. Replies: 3
    Last Post: 2009-06-06, 06:55
  2. how to updated the list box on dialog box before it is displaying it.
    By manjunaths in forum Symbian User Interface
    Replies: 3
    Last Post: 2008-03-20, 10:37
  3. how to move other item on the dialog box
    By manjunaths in forum Symbian User Interface
    Replies: 0
    Last Post: 2006-12-07, 12:46
  4. how to move from list box to text editor on dialog box
    By manjunaths in forum Symbian User Interface
    Replies: 0
    Last Post: 2006-12-07, 10:13

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×