Results 1 to 2 of 2

Thread: space between two tool buttons and hboxlayout

  1. #1
    Join Date
    Aug 2010
    Posts
    14
    Thanks
    2
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default space between two tool buttons and hboxlayout

    I'm trying to remove two tool buttons and add the other widgets and add an hboxlayout using an even filter if the window is shown or hidden. The problem is when I remove the spacer the horizontal one, the two buttons are tied together successfully, but when I add a widget, there is a space between the tool button and the widget as shown in the figure. how would I remove that space ?

    here is the initialization
    Qt Code:
    1. setWindowTitle(tr("Points of Interest"));
    2. m_splitter->setContentsMargins(0, 0, 0, 3);
    3. m_gridLayout = new QGridLayout(this);
    4.  
    5. m_gridLayout->addWidget(m_splitter, 0, 0, 1, 1);
    6. m_hBoxLayout = new QHBoxLayout(this);
    7. m_gridLayout->addLayout(m_hBoxLayout, 1, 0, 1, 1);
    8. m_hBoxLayout->addWidget(m_myPoiButton);
    9. m_hBoxLayout->addStretch();
    10. m_hBoxLayout->addWidget(m_myPoiFilterButton);
    11. m_gridLayout->setVerticalSpacing(0);
    To copy to clipboard, switch view to plain text mode 

    Untitled.png
    Qt Code:
    1. if (event->type() == QEvent::Show)
    2. {
    3. if (obj == m_poiItemWidget)
    4. {
    5. bool visibleName = false, visibleHeight = false, visibleRange = false;
    6. visibleName = m_namePoiFilter.isVisible();
    7. visibleHeight = m_widgetHeight.isVisible();
    8. visibleRange = m_widgetRange.isVisible();
    9.  
    10.  
    11.  
    12.  
    13. m_namePoiFilter.setVisible(visibleName);
    14. m_widgetHeight.setVisible(visibleHeight);
    15. m_widgetRange.setVisible(visibleRange);
    16.  
    17. m_hBoxLayout->addWidget(m_myPoiButton);
    18. for (int i = 0; i < m_hBoxLayout->count(); ++i)
    19. {
    20. QSpacerItem *spacer = m_hBoxLayout->itemAt(i)->spacerItem();
    21. if (spacer)
    22. {
    23. delete m_hBoxLayout->takeAt(i);
    24. break;
    25. }
    26. }
    27. m_hBoxLayout->addWidget(m_myPoiFilterButton);
    28. m_hBoxLayout->addStretch();
    29. m_hBoxLayout->addWidget(&m_namePoiFilter);
    30. m_hBoxLayout->addWidget(&m_widgetHeight);
    31. m_hBoxLayout->addWidget(&m_widgetRange);
    32.  
    33.  
    34. }
    35. }
    36.  
    37. if (event->type() == QEvent::Hide)
    38. {
    39. if (obj == m_poiItemWidget)
    40. {
    41. bool visibleName = false, visibleHeight = false, visibleRange = false;
    42. visibleName = m_namePoiFilter.isVisible();
    43. visibleHeight = m_widgetHeight.isVisible();
    44. visibleRange = m_widgetRange.isVisible();
    45.  
    46.  
    47.  
    48. m_namePoiFilter.setVisible(visibleName);
    49. m_widgetHeight.setVisible(visibleHeight);
    50. m_widgetRange.setVisible(visibleRange);
    51. for (int i = 0; i < m_hBoxLayout->count(); ++i)
    52. {
    53. QSpacerItem *spacer = m_hBoxLayout->itemAt(i)->spacerItem();
    54. if (spacer)
    55. {
    56. delete m_hBoxLayout->takeAt(i);
    57. break;
    58. }
    59. }
    60. m_hBoxLayout->addWidget(m_myPoiButton);
    61. m_hBoxLayout->addStretch();
    62. m_hBoxLayout->addWidget(m_myPoiFilterButton);
    63. m_hBoxLayout->addWidget(&m_namePoiFilter);
    64. m_hBoxLayout->addWidget(&m_widgetHeight);
    65. m_hBoxLayout->addWidget(&m_widgetRange);
    66.  
    67. }
    68.  
    69. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: space between two tool buttons and hboxlayout

    Hard to tell without any screenshot or the ability to execute this, but have you checked if the space is caused by layout spacing?

    Cheers,
    _

Similar Threads

  1. reduce space-size of buttons
    By clepto in forum Qt Programming
    Replies: 7
    Last Post: 31st May 2012, 21:39
  2. Replies: 2
    Last Post: 6th April 2010, 21:42
  3. Grouping of Tool buttons in Tool bar
    By febil in forum Qt Programming
    Replies: 1
    Last Post: 24th March 2009, 11:51
  4. tool buttons on top of label
    By McKee in forum Qt Programming
    Replies: 5
    Last Post: 2nd November 2008, 16:07
  5. Tool Buttons...
    By csvivek in forum Qt Tools
    Replies: 1
    Last Post: 9th May 2008, 07:44

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.