0

I have created a overwrite dialog box as shown below in QT/C++

enter image description here

here is the code associated:

DialogOverwrite::DialogOverwrite(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DialogOverwrite)
{
    ui->setupUi(this);

    QPushButton *YesToAllButton = ui->buttonBox->button(QDialogButtonBox::YesToAll);
    QPushButton *YesButton = ui->buttonBox->button(QDialogButtonBox::Yes);
    QPushButton *NoToAllButton = ui->buttonBox->button(QDialogButtonBox::NoToAll);
    QPushButton *NoButton = ui->buttonBox->button(QDialogButtonBox::No);
    QPushButton *CancelButton = ui->buttonBox->button(QDialogButtonBox::Cancel);

    connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)),this,
        SLOT(dialogButton(QAbstractButton*)));
}

DialogOverwrite::~DialogOverwrite()
{
    delete ui;
}

void DialogOverwrite::dialogButton(QAbstractButton* aButton) {
    QDialogButtonBox::StandardButton button = ui->buttonBox->standardButton(aButton);
    switch (button) {
    case QDialogButtonBox::YesToAll:
        OverwriteAction = YES_TO_ALL;
        break;

....

I have declared QPushButton *YesToAllButton ... in order to connect to the buttonbox design in the ui and triggered the signal clicked.

The triggered works fine but when trying to catch on which button I have clicked, I receive a "NoButton" instead of YesToAll or any other.

Did I miss something

Thanks

Seb
  • 2,929
  • 4
  • 30
  • 73
  • Why do you get the pointers to the buttons in the constructor if you don't use them anywhere? – dtech Apr 01 '15 at 20:56
  • Looks like your roles are not set. Did you bother to check those pointers in the constructor to verify buttons with such roles exist? – dtech Apr 01 '15 at 21:08
  • @ddriver to be honest, when doing it it allow me to triggered the clicked. What I'm looking is just opening the overwrite box if the same file is detected and catch the answer "Yes....No.." before continuing – Seb Apr 01 '15 at 21:45
  • Again - check your roles. You get `NoButton` when it is not a standard button, which means it doesn't have the appropriate role set. I don't say any other reason it will not work. – dtech Apr 01 '15 at 21:50

0 Answers0