Qt Toolbar Question

I am working in various Linux distributions, which may or may not be relevant. I have a QToolBar containing QToolButtons. One of the button labels toggles back and forth between two different texts when the button is pressed. The two labels happen by good fortune to be the same number of letters. I find that when the program is built in some environments, then the very first time I press the button and toggle to the alternate text, all of the toolbar buttons expand vertically (thickness) to occupy the full thickness of the toolbar. I am not switching fonts or anything. Thereafter, when I toggle the text back and forth, nothing changes. This initial re-sizing the first time the button is pressed isn't very desirable, because it makes the thing look amateurish (truthfully, I am a Qt amateur). I tried some things with QSizePolicy, but to no avail. Finally, what I resorted to was that right after the show() command for the window I setText() for the button to the alternate text and then immediately back to the original text to get the resizing out of the way. It all happens too quickly for the user to see. It just seems like a bad way to do it and I wondered if there were another way. I don't really know why the buttons are "slender" initially and then get thicker when the alternate text first appears. Here is my code:

// Toolbar
QToolBar *tool = new QToolBar(createTicketWindow);
tool->setGeometry(2,5,546,20);

QToolButton *acceptButton = new QToolButton;
acceptButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
imageFileName = trayPath + "accept.png";
acceptButton->setIcon(QIcon(imageFileName.c_str()));
acceptButton->setText("accept");
connect(acceptButton, SIGNAL(clicked()), this, SLOT(acceptTicket()));

QToolButton *cancelButton = new QToolButton;
cancelButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
imageFileName = trayPath + "cancel.png";
cancelButton->setIcon(QIcon(imageFileName.c_str()));
cancelButton->setText("Cancel");
connect(cancelButton, SIGNAL(clicked()), this, SLOT(onQuitTicketWindow()));

QToolButton *divButton = new QToolButton;
divButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
imageFileName = trayPath + "div.png";
divButton->setIcon(QIcon(imageFileName.c_str()));
divButton->setText("Importance");

snapButton = new QToolButton;
snapButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
imageFileName = trayPath + "snap.png";
snapButton->setIcon(QIcon(imageFileName.c_str()));
snapButton->setText(snapButtonLabel);

...

tool->addWidget(acceptButton);
tool->addSeparator();
tool->addWidget(cancelButton);
tool->addSeparator();
tool->addWidget(divButton);
tool->addWidget(snapButton);
Topic archived. No new replies allowed.