Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can field() be requested in a QWizard before initialization?
QtWS25 Last Chance

Can field() be requested in a QWizard before initialization?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qwizardqwizardpagefield
1 Posts 1 Posters 539 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RDiGuida
    wrote on 10 Nov 2015, 11:51 last edited by
    #1

    I am calling a QWizardPage from a function in the MainWindow

    void MainWindow::NoiseFilling()
    {
        QWizard *wiz = new QWizard;
        NoiseFillPage *pg = new NoiseFillPage(&data);
        wiz->addPage(pg);
        wiz->setWindowTitle("Noise Filling");
        wiz->setOption(QWizard::NoBackButtonOnStartPage);
    
        QVBoxLayout *ly = new QVBoxLayout;
        QLabel *pb = new QLabel;
        ly->addWidget(wiz);
        ly->addWidget(pb);
    
        connect(wiz,&QDialog::accepted,[&](){data.NoiseFill(wiz->field("percent").toInt(),wiz->field("factor").toString());});  //problem here
        connect(wiz,&QDialog::accepted,[&](){textEdit->setText("Dataset noise filled.\n");});
        delete frame->layout();   // delete previous layout
        frame->setLayout(ly);
        wiz->show();
    }
    

    and the constructor of the WizardPage looks like that

    NoiseFillPage::NoiseFillPage(DataFrame* df,QWidget* parent)
        : QWizardPage(parent)
    {
        box = new QComboBox;
        lab = new QLabel("Metadata factor");
        lab_2 = new QLabel("% of missing values threshold to fill");
        sb = new QSpinBox;
    
        box->insertItem(0,*(df->className));
        box->insertItems(1,*(df->namesMetaData));
    
        sb->setMaximum(100);
        sb->setMinimum(30);
        sb->setValue(100);
    
        QGridLayout *ly = new QGridLayout;
        ly->addWidget(box,0,0);
        ly->addWidget(lab,0,1);
        ly->addWidget(sb,1,0);
        ly->addWidget(lab_2,1,1);
    
        setLayout(ly);
    
        registerField("factor",box);
        registerField("percent",sb);
    }
    

    I receive a segmentation fault when I accept (and therefore close) the dialog of the one-page wizard. The debugger stops on the connect instruction making me believe that the problem arises because I am requesting two fields which are not initialised in compile-time. It is also true that this connection would be made at run time so I am very confused. After narrowing down the issue it seems that it has to do with the call wiz->field("percent"). Does anybody have an idea of what is going on?

    1 Reply Last reply
    0

    1/1

    10 Nov 2015, 11:51

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved