gpt4 book ai didi

c++ - 如何在其他两个之间设置工具栏

转载 作者:行者123 更新时间:2023-11-28 07:53:40 25 4
gpt4 key购买 nike

我有多个工具栏,它们彼此相邻。我希望第一个工具栏成为第三个或另一个工具栏。我不知道如何实现它。谁能帮忙?

这是我的 .cpp 中的内容

 QPixmap pix(16, 16);
pix.fill(Qt::black);
fntColorAct = new QAction(pix, tr("&Color"), this);
connect(fntColorAct, SIGNAL(triggered()), this, SLOT(fontColor()));

fontToolBar = new QToolBar(this);
fontToolBar->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
addToolBar(fontToolBar);
fontToolBar->setWindowTitle(tr("&Format Actions"));
addToolBarBreak(Qt::TopToolBarArea);
addToolBar(fontToolBar);

cmbStyle = new QComboBox(fontToolBar);
fontToolBar->addWidget(cmbStyle);
cmbStyle->addItem("Standard");
cmbStyle->addItem("Bullet List (Disc)");
cmbStyle->addItem("Bullet List (Circle)");
cmbStyle->addItem("Bullet List (Square)");
cmbStyle->addItem("Ordered List (Decimal)");
cmbStyle->addItem("Ordered List (Alpha lower)");
cmbStyle->addItem("Ordered List (Alpha upper)");
cmbStyle->addItem("Ordered List (Roman lower)");
cmbStyle->addItem("Ordered List (Roman upper)");
connect(cmbStyle, SIGNAL(activated(int)), this, SLOT(fontStyle(int)));

fntComboBox = new QFontComboBox(fontToolBar);
fontToolBar->addWidget(fntComboBox);
connect(fntComboBox, SIGNAL(activated(QString)), this, SLOT(fontFamily(QString)));

cmbSize = new QComboBox(fontToolBar);
cmbSize->setObjectName("cmbSize");
fontToolBar->addWidget(cmbSize);
cmbSize->setEditable(true);

QFontDatabase database;
foreach(int size, database.standardSizes())
cmbSize->addItem(QString::number(size));

connect(cmbSize, SIGNAL(activated(QString)),
this, SLOT(fontSize(QString)));
cmbSize->setCurrentIndex(cmbSize->findText(
QString::number(QApplication::font().pointSize())));
}

void MainWindow::createMenus() {
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(newAct);
fileMenu->addAction(openAct);
fileMenu->addAction(saveAct);
fileMenu->addAction(saveAsAct);
fileMenu->addSeparator();
fileMenu->addAction(printAct);
fileMenu->addAction(printPreviewAct);
fileMenu->addSeparator();
fileMenu->addAction(exitAct);

editMenu = menuBar()->addMenu(tr("&Edit"));
editMenu->addAction(cutAct);
editMenu->addAction(copyAct);
editMenu->addAction(pasteAct);
editMenu->addSeparator();
editMenu->addAction(undoAct);
editMenu->addAction(redoAct);

formatMenu = menuBar()->addMenu(tr("Format"));
formatMenu->addAction(boldAct);
formatMenu->addAction(underlineAct);
formatMenu->addAction(italicsAct);
formatMenu->addSeparator()->setText(tr("Alignment"));
formatMenu->addAction(alignLeftAct);
formatMenu->addAction(alignCenterAct);
formatMenu->addAction(alignRightAct);
formatMenu->addAction(justifyAct);
formatMenu->addAction(fntColorAct);

menuBar()->addSeparator();
helpMenu = menuBar()->addMenu(tr("&Help"));
helpMenu->addAction(aboutAct);

menuBar()->addSeparator();
settingsMenu = menuBar()->addMenu(QIcon(":/icons/cog.png"), tr("&Settings")); }

void MainWindow::createToolBars() {
fileToolBar = addToolBar(tr("File"));
fileToolBar->addAction(newAct);
fileToolBar->addAction(openAct);
fileToolBar->addAction(saveAct);

editToolBar = addToolBar(tr("Edit"));
editToolBar->addAction(cutAct);
editToolBar->addAction(copyAct);
editToolBar->addAction(pasteAct);
editToolBar->addAction(undoAct);
editToolBar->addAction(redoAct);

formatToolBar = addToolBar(tr("Format"));
formatToolBar->addAction(boldAct);
formatToolBar->addAction(underlineAct);
formatToolBar->addAction(italicsAct);
formatToolBar->addAction(alignLeftAct);
formatToolBar->addAction(alignCenterAct);
formatToolBar->addAction(alignRightAct);
formatToolBar->addAction(justifyAct);
formatToolBar->addAction(fntColorAct);
}

最佳答案

QMainWindow::insertToolBar()允许您在另一个工具栏之前插入一个工具栏。

关于c++ - 如何在其他两个之间设置工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13223845/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com