[Qt-interest] Hidden Space between QPushButtons

Donal O'Connor donaloconnor at gmail.com
Wed Apr 8 15:39:02 CEST 2009


Hi There,

I want to create a series of QPushButtons across the full width of the
screen on my embedded device with no spacing between them. (i.e. Back to
back)

For each QPushButton, I want it only to be an Icon with no text. The sum of
the total widths of all QPushButtons is 800px, the width of my screen
resolution.

Here is an example of one of the buttons:

 QPushButton *monitoringButton = new
QPushButton(QIcon(":/icons/monitoringicon.png"),"x");

monitoringButton->setStyleSheet("background:none; padding:0px; margin:0px;
border-radius:0px; border:none;");

monitoringButton->setIconSize(QSize(139,56));

monitoringButton->setFixedSize(QSize(139,56));

monitoringButton->setSizePolicy(QSizePolicy::Expanding,

QSizePolicy::Expanding);

monitoringButton->setAutoDefault(false);

monitoringButton->setFlat(true);

I've 5 of these. When I draw them, they over lap. I've noticed that there is
a spacing between each, about 5 px;

These QPushButtons are contained in a Horizontal Layout in a QFrame.
The margin of the layout is 0px; I've set the alignment of the layout to
left alignment;

When I draw the first QPushButton, it works perfectly, the the extreme left
of the screen with no spacing.
However when I draw the next one, it is placed about 5 pixels right to that.
However I want them to be back to back.
This suggests to me that there is a margin on the right of each button.

I am wondering if it is the spacing between the icon and text of the
QPushButton that's the problem. Is it possible to disable the text?

Here is a screen shot of the space:
http://automon.killarneyonline.eu/files/snapshot.png

Thanks,
Donal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090408/48d9db39/attachment.html 


More information about the Qt-interest-old mailing list