clipboard.png
When using the following code, how can I get rid of the spacing between buttons added to the QHBoxLayout, which is inturn added to QFrame?
Usage of "layout->setSpacing(0)" reduced the space between the buttons, but did not remove the space completely.
Attached is screenshot after executing the below code.
Thanks a lot for your help.
#include <QtGui>
int main(int argc,char** argv)
{
window->setCentralWidget(centralWidget);
centralWidget->setLayout(layout);
window->setWindowTitle("Spacing in HBoxLayout");
layout->addStretch(0);
layout->setContentsMargins(0,0,0,0);
layout->setSpacing(0);
window->show();
return app.exec();
}
#include <QtGui>
int main(int argc,char** argv)
{
QApplication app(argc,argv);
QMainWindow* window = new QMainWindow();
QFrame* centralWidget = new QFrame();
QHBoxLayout* layout = new QHBoxLayout();
window->setCentralWidget(centralWidget);
centralWidget->setLayout(layout);
layout->addWidget(new QPushButton("Button 1"));
layout->addWidget(new QPushButton("Button 2"));
window->setWindowTitle("Spacing in HBoxLayout");
layout->addStretch(0);
layout->setContentsMargins(0,0,0,0);
layout->setSpacing(0);
window->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks