#include <QDockWidget>
#include <QSettings>
#include "testrestoredock.h"
TestRestoreDock
::TestRestoreDock(QWidget *parent, Qt
::WFlags flags
){
ui.setupUi(this);
saveStateAction
= new QAction(tr
("&Save State"),
this);
connect(saveStateAction, SIGNAL(triggered()), this, SLOT(SaveState()));
restoreStateAction
= new QAction(tr
("&Restore State"),
this);
connect(restoreStateAction, SIGNAL(triggered()), this, SLOT(RestoreState()));
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(saveStateAction);
fileMenu->addAction(restoreStateAction);
dock->setObjectName(tr("Customers"));
dock->setAllowedAreas(Qt::AllDockWidgetAreas);
<< "John Doe, Harmony Enterprises, 12 Lakeside, Ambleton"
<< "Jane Doe, Memorabilia, 23 Watersedge, Beaton"
<< "Tammy Shea, Tiblanka, 38 Sea Views, Carlton"
<< "Tim Sheen, Caraba Gifts, 48 Ocean Way, Deal"
<< "Sol Harvey, Chicos Coffee, 53 New Springs, Eccleston"
<< "Sally Hobart, Tiroli Tea, 67 Long River, Fedula");
dock->setWidget(customerList);
addDockWidget(Qt::LeftDockWidgetArea, dock);
dock->setObjectName(tr("Paragraphs"));
<< "Thank you for your payment which we have received today."
<< "Your order has been dispatched and should be with you "
"within 28 days."
<< "We have dispatched those items that were in stock. The "
"rest of your order will be dispatched once all the "
"remaining items have arrived at our warehouse. No "
"additional shipping charges will be made."
<< "You made a small overpayment (less than $5) which we "
"will keep on account for you, or return at your request."
<< "You made a small underpayment (less than $1), but we have "
"sent your order anyway. We'll add this underpayment to "
"your next bill."
<< "Unfortunately you did not send enough money. Please remit "
"an additional $. Your order will be dispatched as soon as "
"the complete amount has been received."
<< "You made an overpayment (more than $5). Do you wish to "
"buy more items, or should we return the excess to you?");
dock->setWidget(paragraphsList);
addDockWidget(Qt::LeftDockWidgetArea, dock);
}
TestRestoreDock::~TestRestoreDock()
{}
void TestRestoreDock::SaveState()
{
QSettings settings
("Test",
"Test Dock Problem");
settings.setValue("MainWindow/State", saveState());
settings.setValue("MainWindow/Geometry", geometry());
}
void TestRestoreDock::RestoreState()
{
QSettings settings
("Test",
"Test Dock Problem");
restoreState(settings.value("MainWindow/State").toByteArray());
setGeometry(settings.value("MainWindow/Geometry").toRect());
show();
}
#include <QDockWidget>
#include <QSettings>
#include "testrestoredock.h"
TestRestoreDock::TestRestoreDock(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
saveStateAction = new QAction(tr("&Save State"), this);
connect(saveStateAction, SIGNAL(triggered()), this, SLOT(SaveState()));
restoreStateAction = new QAction(tr("&Restore State"), this);
connect(restoreStateAction, SIGNAL(triggered()), this, SLOT(RestoreState()));
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(saveStateAction);
fileMenu->addAction(restoreStateAction);
QDockWidget *dock = new QDockWidget(tr("Customers"), this);
dock->setObjectName(tr("Customers"));
dock->setAllowedAreas(Qt::AllDockWidgetAreas);
customerList = new QListWidget(dock);
customerList->addItems(QStringList()
<< "John Doe, Harmony Enterprises, 12 Lakeside, Ambleton"
<< "Jane Doe, Memorabilia, 23 Watersedge, Beaton"
<< "Tammy Shea, Tiblanka, 38 Sea Views, Carlton"
<< "Tim Sheen, Caraba Gifts, 48 Ocean Way, Deal"
<< "Sol Harvey, Chicos Coffee, 53 New Springs, Eccleston"
<< "Sally Hobart, Tiroli Tea, 67 Long River, Fedula");
dock->setWidget(customerList);
addDockWidget(Qt::LeftDockWidgetArea, dock);
dock = new QDockWidget(tr("Paragraphs"), this);
dock->setObjectName(tr("Paragraphs"));
paragraphsList = new QListWidget(dock);
paragraphsList->addItems(QStringList()
<< "Thank you for your payment which we have received today."
<< "Your order has been dispatched and should be with you "
"within 28 days."
<< "We have dispatched those items that were in stock. The "
"rest of your order will be dispatched once all the "
"remaining items have arrived at our warehouse. No "
"additional shipping charges will be made."
<< "You made a small overpayment (less than $5) which we "
"will keep on account for you, or return at your request."
<< "You made a small underpayment (less than $1), but we have "
"sent your order anyway. We'll add this underpayment to "
"your next bill."
<< "Unfortunately you did not send enough money. Please remit "
"an additional $. Your order will be dispatched as soon as "
"the complete amount has been received."
<< "You made an overpayment (more than $5). Do you wish to "
"buy more items, or should we return the excess to you?");
dock->setWidget(paragraphsList);
addDockWidget(Qt::LeftDockWidgetArea, dock);
}
TestRestoreDock::~TestRestoreDock()
{}
void TestRestoreDock::SaveState()
{
QSettings settings("Test", "Test Dock Problem");
settings.setValue("MainWindow/State", saveState());
settings.setValue("MainWindow/Geometry", geometry());
}
void TestRestoreDock::RestoreState()
{
QSettings settings("Test", "Test Dock Problem");
restoreState(settings.value("MainWindow/State").toByteArray());
setGeometry(settings.value("MainWindow/Geometry").toRect());
show();
}
To copy to clipboard, switch view to plain text mode
Bookmarks