View Full Version : how align some buttons in QToolbar from right to left?
davi_all4one
7th September 2009, 09:52
I have to local two QToolbars at the top of the main window. The button in one ist aligned right-to-left.
Thank for the Help
victor.fernandez
7th September 2009, 10:36
Create a blank widget and set its horizontal size policy to QSizePolicy::Expanding. Add that widget before all the actions. This way, the widget will act like a spacer, making the rest of toolbuttons appear at the right side. For example:
#include <QtGui>
#include "mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
QToolBar *toolBar = addToolBar(tr("Main toolbar"));
QWidget *spacerWidget = new QWidget(this);
spacerWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
spacerWidget->setVisible(true);
QAction *myAction = new QAction(tr("Exit"), this);
toolBar->addWidget(spacerWidget);
toolBar->addAction(myAction);
}
victor.fernandez
7th September 2009, 10:41
Oops! Sorry, I didn't realise you're talking about Qt 3.
davi_all4one
7th September 2009, 11:15
nonetheless, thx:p
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.