В QT я новичок. Версия QT - 4.3, на пингвине. Прога состоит из main.cpp, share.h, share.cpp. Как мне автоматически выполнить функцию smb_conf() сразу после запуска программы? Какой обьект с каким сигналом соиденять? Раньше на Delphi это было просто - у формы выбирал OnActivate и вставлял функцию...
main.cpp
#include <QApplication>
#include "share.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
share *dialog = new share;
dialog->show();
return app.exec();
}
#ifndef SHARE_H
#define SHARE_H
#include "ui_share.h"
class share : public QDialog, private Ui::dialogs
{
Q_OBJECT
public:
share(QDialog *parent = 0);
public slots:
void getPath();
void smb_conf();
};
#endif
#include <QtGui>
#include "share.h"
share::share(QDialog *parent)
{
setupUi(this);
connect( pushButton_2, SIGNAL( clicked() ), this, SLOT( getPath() ) );
}
void share::getPath() {
QString path;
path = QFileDialog::getExistingDirectory(
this,
"Choose a folder",
QDir::currentPath()
);
lineEdit_3->setText( path );
}
void share::smb_conf () {
int unsigned i = 0, linecounter = 0;
QString tx;
QString name[30];
QFile fa ("/home/tintix/Desktop/smb.conf");
---------//Что-то происходит//--------------
lineEdit->setText(name[0]);
}
В Qt можно соединить слот со слотом, сделай что-то вроде этого:
a.connect( this, SLOT(show()), this, SLOT( smb_conf()));
a.connect( this, SLOT(show()), this, SLOT( smb_conf()));
По твоему вопросу думаю должен помочь http://www.crossplatform.ru/documentation/qtdoc4.3/qshowevent.php, хотя может быть есть и решение попроще.
Попробую сварганить пример...
А что мешает вызывать smb_conf() прямо из конструктора диалога?
Форум Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)