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
){
QToolBar *toolBar
= addToolBar
(tr
("Main toolbar"));
spacerWidget->setVisible(true);
toolBar->addWidget(spacerWidget);
toolBar->addAction(myAction);
}
#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);
}
To copy to clipboard, switch view to plain text mode
Bookmarks