#include <QtCore>
#include <QtGui>
{
public:
{
t
->addAction
(new QAction("Act1",
this));
t
->addAction
(new QAction("Act2",
this));
t
->addAction
(new QAction("Act3",
this));
addToolBar(t);
if(restoreState(s.value("MainWindowState").toByteArray()))
{
// creation of second toolbar depends on user interaction
// for example second run
t
->addAction
(new QAction("Act1",
this));
t
->addAction
(new QAction("Act2",
this));
t
->addAction
(new QAction("Act3",
this));
addToolBar(t);
}
}
~Window(void)
{
s.setValue("MainWindowState",saveState());
}
private:
};
int main(int argc, char *argv[])
{
Window window;
window.show();
return app.exec();
}
#include <QtCore>
#include <QtGui>
class Window: public QMainWindow
{
public:
Window(void):QMainWindow()
{
t=new QToolBar("Toolbar1",this);
t->addAction(new QAction("Act1",this));
t->addAction(new QAction("Act2",this));
t->addAction(new QAction("Act3",this));
addToolBar(t);
QSettings s("Trolltech","TestAPP");
if(restoreState(s.value("MainWindowState").toByteArray()))
{
// creation of second toolbar depends on user interaction
// for example second run
t=new QToolBar("Toolbar2",this);
t->addAction(new QAction("Act1",this));
t->addAction(new QAction("Act2",this));
t->addAction(new QAction("Act3",this));
addToolBar(t);
}
}
~Window(void)
{
QSettings s("Trolltech","TestAPP");
s.setValue("MainWindowState",saveState());
}
private:
QToolBar* t;
};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Window window;
window.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks