Thank you - this is the final solution that worked for me
helpDialog.h - same as above
in helpDialog.cpp:
HelpDialog
::HelpDialog(QWidget *const theParent
) , ui(new Ui::HelpDialog)
{
ui->setupUi(this);
// display the dialog on the right of the current screen.
if (nullptr != theParent)
{
setWindowFlags(Qt::Window); //ensure the minimize button on the QDialog
}
}
HelpDialog::HelpDialog(QWidget *const theParent)
: QDialog(theParent)
, ui(new Ui::HelpDialog)
{
ui->setupUi(this);
// display the dialog on the right of the current screen.
if (nullptr != theParent)
{
setWindowFlags(Qt::Window); //ensure the minimize button on the QDialog
}
}
To copy to clipboard, switch view to plain text mode
in code for main application window to bring this up:
in class init() function:
myHelpDialog = new HelpDialog(this);
//lamba to handle pressing of help button
const auto ToggleHelp = [this]()
{
const QString HelpText
= tr
("Some help text goes here");
if (isVisible())
{
myHelpDialog ->setMessage(HelpText);
//place help dialog "top right" corner just inside the top right corner of parent window
QRect rect
= myHelpDialog
->geometry
();
//get current geometry of help window QRect parentRect
= this
->geometry
();
//get current geometry of this window rect.
moveTo(mapToGlobal
(QPoint(parentRect.
x() + parentRect.
width() - rect.
width(), parentRect.
y())));
myHelpDialog ->setGeometry(rect);
myHelpDialog ->show(); //use show for nonmodal dialogs
}
};
( void )connect(m_footerWidget, &FooterWidget::helpButtonClicked, ToggleHelp);
myHelpDialog ->hide();
myHelpDialog = new HelpDialog(this);
//lamba to handle pressing of help button
const auto ToggleHelp = [this]()
{
const QString HelpText = tr("Some help text goes here");
if (isVisible())
{
myHelpDialog ->setMessage(HelpText);
//place help dialog "top right" corner just inside the top right corner of parent window
QRect rect = myHelpDialog->geometry(); //get current geometry of help window
QRect parentRect = this->geometry(); //get current geometry of this window
rect.moveTo(mapToGlobal(QPoint(parentRect.x() + parentRect.width() - rect.width(), parentRect.y())));
myHelpDialog ->setGeometry(rect);
myHelpDialog ->show(); //use show for nonmodal dialogs
}
};
( void )connect(m_footerWidget, &FooterWidget::helpButtonClicked, ToggleHelp);
myHelpDialog ->hide();
To copy to clipboard, switch view to plain text mode
Bookmarks