Results 1 to 14 of 14

Thread: dont want to scroll

  1. #1
    Join Date
    Mar 2011
    Posts
    51
    Thanks
    7
    Qt products
    Qt3 Qt4 Qt/Embedded

    Default dont want to scroll

    hello every one i want to ask that i have a main widget i which there are some buttons label list box etc and also 2 scroll areas in scroll area i show the graph. but as the name suggest that in scroll area my whole graph is not visible at one time. i want to show my whole graph at time in the same space means that graph must adjust to fit in that particular area what should i do some one suggest me QVBoxLayout but i don't find it in the tool list .

    so far i have sone this

    Qt Code:
    1. myplot * p = new myplot(gao.structpayloadgraph,gao1.structpayloadgraph, gao.structcol-2, "payload");
    2.  
    3. myplot * p1 = new myplot(gao.structsessiongraph,gao.structsessiongraph ,gao.structcol-2, "session");
    4. p->resize(ui->scrollArea->size().width() ,ui->scrollArea->size().height());
    5. p->show();
    6. p1->resize(ui->scrollArea_2->size().width() ,ui->scrollArea_2->size().height());
    7. p1->show();
    8. ui->scrollArea->setWidget(p);
    9. ui->scrollArea_2->setWidget(p1);
    To copy to clipboard, switch view to plain text mode 


    kindly help me i will be very thank full to you

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: dont want to scroll

    some one suggest me QVBoxLayout but ....
    You can use QVBoxLayout, or other Layout managers
    i don't find it in the tool list
    What do you mean? QVBoxLayout is in Qt frame work.

  3. #3
    Join Date
    Mar 2011
    Posts
    51
    Thanks
    7
    Qt products
    Qt3 Qt4 Qt/Embedded

    Default Re: dont want to scroll

    yes sir i have no idea how to use it. what should i do to solve my problem

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: dont want to scroll

    QLayout Documentation will be a good place to start from, please try the examples, if still find problem using it, forum is open
    http://doc.qt.nokia.com/latest/examples-layouts.html

  5. #5
    Join Date
    Mar 2011
    Posts
    51
    Thanks
    7
    Qt products
    Qt3 Qt4 Qt/Embedded

    Default Re: dont want to scroll

    thank u sir for your response but please tell me is there a way to remeove scrollbar and just show the complete picture at once

    thanks

  6. #6
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: dont want to scroll

    don;t use QScrollBar, directly add the plot widget on to the main widget's layout, I can give you an example, fit this into you application

    Qt Code:
    1. QHBoxLayout * layout = new QHBoxLayout;
    2. mainWidget->setLayout(layout);
    3.  
    4. layout->addWidget(button); // adding button to layout
    5. layout->addWidget(label); // adding label to layout
    6. layout->addWidget(p1); // adding plot 1 to layout
    7. layout->addWidget(p2); // adding plot 1 to layout
    To copy to clipboard, switch view to plain text mode 

  7. The following user says thank you to Santosh Reddy for this useful post:

    maarvi (27th June 2011)

  8. #7
    Join Date
    Mar 2011
    Posts
    51
    Thanks
    7
    Qt products
    Qt3 Qt4 Qt/Embedded

    Default Re: dont want to scroll

    sir i did

    Qt Code:
    1. ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    2. ui-> scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    3. ui-> scrollArea->setWidgetResizable(false);
    To copy to clipboard, switch view to plain text mode 


    now my scrollbars are removed but now the problem is that my myplot object "p" is not taking the full space in scroll bar area. it is squeezed even though i wrote
    Qt Code:
    1. p->resize(ui->scrollArea->size().width() ,ui->scrollArea->size().height());
    To copy to clipboard, switch view to plain text mode 

    what should i do to resize it

  9. #8
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: dont want to scroll

    it does not matter if you remove the scroll bars, you should remove the QScrollArea. Don't use QScrollArea at all, if your want your widgets to fit to the available space. Did you understand my example

  10. The following user says thank you to Santosh Reddy for this useful post:

    maarvi (27th June 2011)

  11. #9
    Join Date
    Mar 2011
    Posts
    51
    Thanks
    7
    Qt products
    Qt3 Qt4 Qt/Embedded

    Default Re: dont want to scroll

    yes sir i got it thanks but i think i will need you help with the layout more. thanks

  12. #10
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: dont want to scroll

    Sure, you are welcome

  13. #11
    Join Date
    Mar 2011
    Posts
    51
    Thanks
    7
    Qt products
    Qt3 Qt4 Qt/Embedded

    Default Re: dont want to scroll

    Sir i got an other problem i am calling all these statements in my button event handler like this
    Qt Code:
    1. void analysis::on_pushButton_clicked()
    2. {
    3. myplot * p = new myplot(gao.structpayloadgraph,gao1.structpayloadgraph, gao.structcol-2, "payload");
    4.  
    5. myplot * p1 = new myplot(gao.structsessiongraph,gao.structsessiongraph ,gao.structcol-2, "session");
    6.  
    7.  
    8. QHBoxLayout * layout = new QHBoxLayout;
    9. ui->horizontalLayout_2->addLayout(layout);
    10. layout->addWidget(p);
    11. layout->addWidget(p1);
    12. }
    To copy to clipboard, switch view to plain text mode 

    but the problem is that each time i click the button new graph appear and previous remains, like one !st click 2 appear on second they become 4 then 6......
    how to i destroy QHBoxLayout in my button event handler

    thanks

  14. #12
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: dont want to scroll

    Add this in the beginning of the slot (i assume ui->horizontalLayout_2 does not have anything else, other than the layout you add)

    Qt Code:
    1. void analysis::on_pushButton_clicked()
    2. {
    3. QLayoutItem *child;
    4. while ((child = ui->horizontalLayout_2->takeAt(0)) != 0) {
    5. delete child;
    6. }
    7.  
    8. ....
    9. }
    To copy to clipboard, switch view to plain text mode 

  15. The following user says thank you to Santosh Reddy for this useful post:

    maarvi (27th June 2011)

  16. #13
    Join Date
    Mar 2011
    Posts
    51
    Thanks
    7
    Qt products
    Qt3 Qt4 Qt/Embedded

    Default Re: dont want to scroll

    thank u so much sir for your help


    Added after 5 minutes:


    sir the previous on is still not removing now graph is drawn over one an other
    Last edited by maarvi; 27th June 2011 at 13:19.

  17. #14
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: dont want to scroll

    See your other thread: http://www.qtcentre.org/threads/42750-destroy-QHBoxLayout

    Please refrain from asking the same question in multiple places.

Similar Threads

  1. I dont see any linewidth on a splitter ...
    By tonnot in forum Newbie
    Replies: 3
    Last Post: 31st March 2011, 21:06
  2. QDial disabling key scroll and mouse wheel scroll
    By ldg20 in forum Qt Programming
    Replies: 2
    Last Post: 2nd June 2010, 23:05
  3. Replies: 0
    Last Post: 28th December 2009, 12:24
  4. QGraphicsView dont refresh
    By ProTonS in forum Qt Programming
    Replies: 2
    Last Post: 11th September 2009, 14:05
  5. Replies: 6
    Last Post: 14th April 2006, 05:39

Tags for this Thread

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.