Here's an example illustrating what I meant:
#include <QtGui>
int main(int argc, char* argv[])
{
QMenu* fileMenu
= window.
menuBar()->addMenu
("File");
fileMenu->addAction("Quit", &window, SLOT(close()));
for (int i = 0; i < 3; ++i)
{
QMenu* menu
= textEdit
->createStandardContextMenu
();
toolBar->addActions(menu->actions());
wrapper->addToolBar(Qt::TopToolBarArea, toolBar);
wrapper->setCentralWidget(textEdit);
tabWidget
->addTab
(wrapper,
QString::number(i
));
}
window.setCentralWidget(tabWidget);
window.show();
return app.exec();
}
#include <QtGui>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QMainWindow window;
QMenu* fileMenu = window.menuBar()->addMenu("File");
fileMenu->addAction("Quit", &window, SLOT(close()));
QTabWidget* tabWidget = new QTabWidget(&window);
for (int i = 0; i < 3; ++i)
{
QMainWindow* wrapper = new QMainWindow(tabWidget);
QTextEdit* textEdit = new QTextEdit(wrapper);
QToolBar* toolBar = new QToolBar(wrapper);
QMenu* menu = textEdit->createStandardContextMenu();
toolBar->addActions(menu->actions());
wrapper->addToolBar(Qt::TopToolBarArea, toolBar);
wrapper->setCentralWidget(textEdit);
tabWidget->addTab(wrapper, QString::number(i));
}
window.setCentralWidget(tabWidget);
window.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Notice the usage of a wrapper QMainWindow inside QTabWidget.
Bookmarks