just started using qt, looked through docs, google, examples, etc.. trying to find simple examples(working mind you) that showed how to do (imho) simple things, by themselves. well i stumbled upon my answer and i was wondering if this approach would cause an issue later as the code becomes more complex. there are more includes than needed for this example, but this is direct from working code. mainwindow.h: i added
private slots:
void vpkButton_clicked();
and after Ui::MainWindow *ui; i added QLineEdit *vpkPathTxt; in mainwindow.cpp: after
ui->setupUi(this);
i added
connect( this->ui->vpkButton, SIGNAL( clicked() ), this, SLOT(vpkButton_clicked()) );
to connect my ui button to the proper slot, the issue was getting the string from vpkButton_clicked() to display in the line edit i made in the designer, what ended up working for me was adding this next:
vpkPathTxt = this->ui->vpkPathTxt;
the function in my main.cpp became very easy: (QString declarations at top outside voids)
void MainWindow::vpkButton_clicked()
{
vpkName = QFileDialog::getOpenFileName(this,
tr("Open VPK File"), "~/", tr("VPK Files (*_dir.vpk)"));
vpkPathTxt->setText(vpkName);
qDebug() << vpkName;
}
the reason i am ask is because it seems a little too easy to be reliable, and the fact that i havent seen it done like this, any input welcome thankyou