Sorry it took so long to reply, I got pulled away for another project and just didn't have time to check on this. I know it only takes a few minutes, but when you have someone breathing down your back, you know how it is. This is what I have. If you're saying to make 2 customized widgets (dialogs?) and then put them in on each side of another dialog, if I have to do that much work it would pretty much be the same as making 2 dialog widgets from Qt Designer. Actually, less work. Anyway, this is what I have. I'm including screen shots of the windows, the one from Qt Designer and the two windows displayed during the program. I put what I thought would be the pertinent code for what I'm trying to do with the dialog widget from the .cpp file. The whole file would just be too much code that has nothing to do with this part.
// .cpp
#include "caddguestsdialog.h"
#include "ckeyboardloguser.h"
#include <QMetaProperty>
#include <QStandardItem>
#include <QWindow>
#include <QMessageBox>
// the pointer *pLogUserMainWindow is a pointer back to the creating window (the parameter passed form the mainwindow during dialog creation is "this").
// It lets me recast it as (CKeyboardLogUserClient*) during operation and call the public functions from the parent
// the same as the parent can call the public functions of the child. I tried recasting *parent, but it doesn't work.
{
ui.setupUi(this);
m_str_lst_Users = str_lst_Users;
ui.m_combobox_Users->addItems(m_str_lst_Users)
ui.m_lbl_GuestListTitle->hide();
ui.m_txt_CustomerList->hide(); // QPlainTextEdit
ui.m_btn_CancelAfterVerification->hide();
ui.m_btn_Finished->hide();
m_pLogUserMainWindow = pLogUserMainWindow;
SetupConnections();
}
void CAddGuestsDialog::PinValidated(bool bValidated)
{
if (bValidated)
{
ui.m_lbl_GuestListTitle->show();
ui.m_txt_CustomerList->show();
ui.m_btn_CancelAfterVerification->show();
ui.m_btn_Finished->show();
ui.m_lbl_AuthorizingUserTitle->hide();
ui.m_combobox_Users->hide();
ui.m_lbl_Pin->hide();
ui.m_txt_Pin->hide(); // QLineEdit
ui.m_btn_SubmitForAuth->hide();
ui.m_btn_CancelBeforeVerification->hide();
adjustSize();
}
else
{
QMessageBox::information(this, tr
("Incorrect Pin"), tr
("The user name and pin didn't match"));
}
}
{
adjustSize();
}
// .cpp
#include "caddguestsdialog.h"
#include "ckeyboardloguser.h"
#include <QMetaProperty>
#include <QStandardItem>
#include <QWindow>
#include <QMessageBox>
// the pointer *pLogUserMainWindow is a pointer back to the creating window (the parameter passed form the mainwindow during dialog creation is "this").
// It lets me recast it as (CKeyboardLogUserClient*) during operation and call the public functions from the parent
// the same as the parent can call the public functions of the child. I tried recasting *parent, but it doesn't work.
CAddGuestsDialog::CAddGuestsDialog(QMainWindow *pLogUserMainWindow, QStringList str_lst_Users, QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
m_str_lst_Users = str_lst_Users;
ui.m_combobox_Users->addItems(m_str_lst_Users)
ui.m_lbl_GuestListTitle->hide();
ui.m_txt_CustomerList->hide(); // QPlainTextEdit
ui.m_btn_CancelAfterVerification->hide();
ui.m_btn_Finished->hide();
m_pLogUserMainWindow = pLogUserMainWindow;
SetupConnections();
}
void CAddGuestsDialog::PinValidated(bool bValidated)
{
if (bValidated)
{
ui.m_lbl_GuestListTitle->show();
ui.m_txt_CustomerList->show();
ui.m_btn_CancelAfterVerification->show();
ui.m_btn_Finished->show();
ui.m_lbl_AuthorizingUserTitle->hide();
ui.m_combobox_Users->hide();
ui.m_lbl_Pin->hide();
ui.m_txt_Pin->hide(); // QLineEdit
ui.m_btn_SubmitForAuth->hide();
ui.m_btn_CancelBeforeVerification->hide();
adjustSize();
}
else
{
QMessageBox::information(this, tr("Incorrect Pin"), tr("The user name and pin didn't match"));
}
}
void showEvent(QShowEvent *event)
{
adjustSize();
}
To copy to clipboard, switch view to plain text mode
// .h
#ifndef CADDGUESTSDIALOG_H
#define CADDGUESTSDIALOG_H
#include <QDialog>
#include <QMainWindow>
//#include "ckeyboardloguser.h"
#include "ui_caddguestsdialog.h"
class CAddGuestsDialog
: public QDialog{
Q_OBJECT
public:
CAddGuestsDialog
(QWidget *parent
= 0);
~CAddGuestsDialog();
void PinValidated(bool bValidated);
protected:
private:
Ui::CAddGuestsDialog ui;
int m_nSelectedTextStart;
int m_nSelectedTextSize;
int m_nCursorPosOld;
int m_nCursorPosNew;
void SetupConnections();
private slots:
void OnButtonClicked_Cancel();
void OnButtonClicked_Finished();
void OnButtonClicked_SubmitForAuthorization();
void OnPinCursorMoved(int nOld, int nNew);
void OnPinTextSelectionChanged();
};
#endif // CADDGUESTSDIALOG_H
// .h
#ifndef CADDGUESTSDIALOG_H
#define CADDGUESTSDIALOG_H
#include <QDialog>
#include <QMainWindow>
//#include "ckeyboardloguser.h"
#include "ui_caddguestsdialog.h"
class CAddGuestsDialog : public QDialog
{
Q_OBJECT
public:
CAddGuestsDialog(QWidget *parent = 0);
CAddGuestsDialog(QMainWindow *pLogUserMainWindow, QStringList str_lst_Users , QWidget *parent = 0);
~CAddGuestsDialog();
QStringList GetCustomerList();
QString GetApprovingUser();
void PinValidated(bool bValidated);
protected:
virtual void showEvent(QShowEvent *event);
private:
QMainWindow *m_pLogUserMainWindow;
Ui::CAddGuestsDialog ui;
QString m_str_ApprovingUser;
QStringList m_str_lst_Customers;
QStringList m_str_lst_Users;
QString m_str_CurrentPin;
int m_nSelectedTextStart;
int m_nSelectedTextSize;
int m_nCursorPosOld;
int m_nCursorPosNew;
void SetupConnections();
private slots:
void OnButtonClicked_Cancel();
void OnButtonClicked_Finished();
void OnButtonClicked_SubmitForAuthorization();
void OnPinCursorMoved(int nOld, int nNew);
void OnPinTextSelectionChanged();
QString OnTextEdited_Pin(QString str_Pin);
};
#endif // CADDGUESTSDIALOG_H
To copy to clipboard, switch view to plain text mode
Bookmarks