Results 1 to 4 of 4

Thread: problems with layout - (stretch)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2010
    Posts
    17
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    8

    Default problems with layout - (stretch)

    Hi to all, i have one problem with a QVBoxLayout.
    at first a list of messages are loaded into a QScrollArea. Those panels(messages) have a button to display its parameters in other panels below the message panel.
    The problem is that when i try to insert the parameters penls below the message panel, they are displayed with space between them, and i dont know hot to display them together with no space.

    here is the code to load the messages.It works well.

    Qt Code:
    1. QWidget *scrollWidget = ui.scrollTx;
    2. QVBoxLayout *layout = (QVBoxLayout*) scrollWidget->layout ();
    3.  
    4.  
    5. //Creo los nuevos paneles y los añado a la lista.
    6. for (it = m_cListaTx.begin (); it != m_cListaTx.end ();)
    7. {
    8. CArincMsgData *msg = *it;
    9. if (msg)
    10. {
    11. PanelTx *panel = new PanelTx (msg, *this, layout->widget());
    12. layout->addWidget (panel);
    13. }
    14. it++;
    15. }
    16. ((QVBoxLayout *)layout)->addStretch ();
    To copy to clipboard, switch view to plain text mode 
    when i addStretch, all the panels are displayed together with no space between them..



    and here is the code i have problems with

    Qt Code:
    1. QWidget *scrollWidget = ui.scrollTx;
    2. QVBoxLayout *layout = (QVBoxLayout *)scrollWidget->layout ();
    3.  
    4. int i;
    5. for (i = 0, it = m_cListaTx.begin(); it != m_cListaTx.end (); it++, i++)
    6. {
    7. //localizo el panel
    8. msg = *it;
    9. panel = m_cListaPanelsTx[msg->getLabel()];
    10. if( label == atoi(msg->getStrLabel().c_str ()) )
    11. {
    12. //when i locate the message i create as many parameter panel as it has
    13.  
    14. params = msg->getParametros ();
    15. for(int j = 0; j < params.size(); j++)
    16. {
    17. OutputDebugStringA ("voy a insertar un panel\n");
    18.  
    19. //create a panel
    20. PanelTxParams *panelParametro = new PanelTxParams (layout->widget(),params[j],msg->getStrLabel ());
    21.  
    22. layout->insertWidget(++i,panelParametro);
    23. }
    24. ......
    To copy to clipboard, switch view to plain text mode 

    in this part im not using addstretch() cause i have used at messages loading. But if i use it the result is not the desirable.

    when i insert the parameters panels they are not displayed together, but they are displayed with some lines of space between them.

    other thing is that in other function i have to insert the same message panels and it works fine, but with those new panels (parameter panels) the result is different.

    how can i get this working fine?

    thanks a lot
    Last edited by pakine; 25th August 2010 at 11:53. Reason: more info

Similar Threads

  1. Problems with layout
    By franco.amato in forum Qt Programming
    Replies: 6
    Last Post: 21st January 2010, 15:42
  2. QWidget layout problems
    By MarkoSan in forum Newbie
    Replies: 3
    Last Post: 12th January 2010, 10:23
  3. Problems with QMainWindow and layout
    By franco.amato in forum Qt Programming
    Replies: 2
    Last Post: 24th November 2009, 22:49
  4. Qt layout space + stretch
    By bunjee in forum Qt Programming
    Replies: 3
    Last Post: 20th December 2007, 15:53
  5. Resizing problems when applying a layout
    By JimBrown in forum Newbie
    Replies: 1
    Last Post: 21st February 2007, 22:54

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
  •  
Qt is a trademark of The Qt Company.