我正在创建的程序包括Dim tempLong As Double
tempLong = Radians(longD) + ArcTan2(Sin(bearingR) * sinAngDistance * Cos(latR), cosAngDistance - Sin(latR) * Sin(latlong(0)))
' set longitude if calculated value less than 1
If tempLong < 1 Then
latlong(1) = tempLong
' if greater than 1, add decimal part back to modulus result
Else
Dim decLong As Double
decLong = tempLong
While decLong > 1
decLong = decLong - 1
Wend
latlong(1) = ((tempLong + 540) Mod 360 - 180) + decLong
End If
部分。我要执行以下功能:
当我尝试按扮演{strong>撤消角色的QTextEdit
项目时,
撤消的跟踪历史记录的结尾时,必须返回具体值(QAction
或bool
)。我猜想成功执行完上述命令后,将执行另一个命令。
重做必须执行相同的操作。
谢谢。
答案 0 :(得分:1)
在Qt QTextEdit
documentation中,您可以找到redo
和undo
动作。您还可以通过redo
和undo
信号测试redoAvailable
或undoAvailable
是否可用。
要执行操作,您可以使用信号/插槽注册。
例如:
#include <QVBoxLayout>
#include <QPushButton>
#include <QTextEdit>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
QPushButton *poUndo = new QPushButton("Undo", this);
QPushButton *poRedo = new QPushButton("Redo", this);
QTextEdit *poTextEdit = new QTextEdit(this);
QHBoxLayout *poHlayout = new QHBoxLayout;
QLabel * poLabelRedoAvaliable = new QLabel(this);
QLabel * poLabelUndoAvaliable = new QLabel(this);
// add undo/redo buttons
poHlayout->addWidget(poRedo);
poHlayout->addWidget(poUndo);
QVBoxLayout *poVLayout = new QVBoxLayout;
poVLayout->addWidget(poTextEdit); // add text edit
poVLayout->addLayout(poHlayout);
// redo/undo avaliable status
poVLayout->addWidget(poLabelRedoAvaliable);
poVLayout->addWidget(poLabelUndoAvaliable);
// main central widget
QWidget *poCentral = new QWidget(this);
poCentral->setLayout(poVLayout);
this->setCentralWidget(poCentral);
// register the undo/redo actions actions
connect(poUndo, &QPushButton::clicked, poTextEdit, &QTextEdit::undo);
connect(poRedo, &QPushButton::clicked, poTextEdit, &QTextEdit::redo);
connect(poTextEdit, &QTextEdit::redoAvailable,
[poLabelRedoAvaliable](bool bAvailable)
{
if (bAvailable)
{
poLabelRedoAvaliable->setText("redo available");
}
else {
poLabelRedoAvaliable->setText("redo not available");
}
});
connect(poTextEdit, &QTextEdit::undoAvailable,
[poLabelUndoAvaliable](bool bAvailable)
{
if (bAvailable)
{
poLabelUndoAvaliable->setText("undo available");
}
else {
poLabelUndoAvaliable->setText("undo not available");
}
});
}