Results 1 to 6 of 6

Thread: size of horizontal layout

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

    Default size of horizontal layout

    hello every one this is my code

    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.  
    5. ui->horizontalLayout_3->addWidget(p);
    6.  
    7. ui->horizontalLayout_3->addWidget(p1);
    To copy to clipboard, switch view to plain text mode 

    its working fine my graph are shown side by size but the problem is that it is good for small graphs having 5 ,6 points but when i try to show some bigger graph the window(in which graph is shown) become extremely large the it didn't fit on screen so is there a way by which i can take the size of horizontal layout and then resize my p , p1 to fit in to that area something like that

    thankss

  2. #2
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: size of horizontal layout

    You should base your size calculations on the widget on which the horizontalLayout_3 is set.

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

    Default Re: size of horizontal layout

    Sorry sir i didnt get you can you please explain a lil bit more

  4. #4
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: size of horizontal layout

    Assuming that there is some piece of code written by you or qt designer:
    Qt Code:
    1. QWidget w = new QWidget(this);
    2. w.setLayout(horizontalLayout_3);
    To copy to clipboard, switch view to plain text mode 

    You can calculate the available area by getting size of the widget "w". Remember thought, that there can be some other widgets, margins or spacing set in that layout also.

  5. #5
    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: size of horizontal layout

    IMO calculating size on widgets, and adjusting the graphs my not be a good solution, as it will it is still restricted by the screen size, you should use QScrollArea.

    I remember you had a problem using QScrollArea earlier, is it with same application? You need to add objects in this hierarchy

    graph1 -> h_layout1 -> widget1 -> scroll area1 -> h_layout_main -> main widget
    graph2 -> h_layout2 -> widget2 -> scroll area2 -> h_layout_main -> main widget

    (add graph to layout, set layout on widget, set widget on a scroll area, add scroll area to layout, set layout on main widget)

    or even this will work,
    graph1 -> scroll area1 -> h_layout_main -> main widget
    graph2 -> scroll area2 -> h_layout_main -> main widget

    You can either use Qt Designer / code to achieve this.

  6. #6
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: size of horizontal layout

    IMO calculating size on widgets, and adjusting the graphs my not be a good solution, as it will it is still restricted by the screen size, you should use QScrollArea.
    Agree with that 100%, but The following quote explains exactly why I propsed that solution

    I remember you had a problem using QScrollArea earlier, is it with same application?

Similar Threads

  1. Replies: 0
    Last Post: 12th December 2010, 05:09
  2. Replies: 0
    Last Post: 26th October 2010, 17:59
  3. Adjust the initial size of a QTextEdit in a layout
    By hecinho in forum Qt Programming
    Replies: 0
    Last Post: 26th November 2009, 15:58
  4. Replies: 0
    Last Post: 25th May 2009, 10:00
  5. Qt Layout engine not respecting minimum size?
    By Mike in forum Qt Programming
    Replies: 2
    Last Post: 28th August 2007, 13:27

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.