|
|
Source code |
1 2 3 4 |
void my_class::read_file()
{
infile=fopen("file.obj","r+");
|
|
|
Source code |
1 2 3 4 5 6 |
MainWindow::MainWindow
{
...............................................
loa_file = new QToolButton(this);
load_file->setObjectName(QString::fromUtf8("load_file""));
load-file->setGeometry(QRect(10, 10, 51, 31));
|
the signal is not clicked to button ?
Quoted
and you can connect it to any signal that emits a QString
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
connect(some_button, SIGNAL(clicked()), my_class_ptr, SLOT(get_and_read_file()))
...
void my_class::read_file(QString fname)
{
infile=fopen("file.obj","r+"); // why use fopen? use fstream (c++) or Qfile (Qt)
}
QString my_class::get_filename()
{
return QFileDialog::getOpenFileName();
}
// must be in section 'public slots:' or 'private slots:' in header file
void my_class::get_and_read_file()
{
QString filename = get_filename();
read_file(filename);
}
|
|
|
Source code |
1 2 3 4 |
MainWindow::MainWindow()
{
my_widget = new my_class(this);
connect(repo_O, SIGNAL(clicked()), my_widget, SLOT(get_and_read_file()));
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 |
class my_class: public my_class
{
Q_OBJECT
..................................
public slots:
void get_and_read_file();
protected:
virtual void paintEvent(QPaintEvent *e);
virtual void showEvent(QShowEvent *e);
virtual void Read_file(QString fname);
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
void my_class::get_and_read_file()
{
QString filename = get_filename();
Read_file(filename);
}
QString my_class::get_filename()
{
return QFileDialog::getOpenFileName();
}
void my_class:: Read_file(QString fname)
{
const char* my_file=fname.toStdString().c_str();
infile=fopen(my_file,"rb+");
|
|
|
Source code |
1 2 3 4 5 |
repo_O = new QToolButton(page_13);
repo_O->setObjectName(QString::fromUtf8("repo_O"));
repo_O->setGeometry(QRect(60, 10, 31, 31));
repo_O->setText(QApplication::translate("MainWindow", "...", 0, QApplication::UnicodeUTF8));
connect(repo_O, SIGNAL(clicked()), ogreWidget, SLOT(get_and_read_file()));
|
|
|
Source code |
1 2 3 |
QFile file(file_name); file.open(QFile::ReadWrite); QByteArray contents = file.readAll(); |
I don't think you would have to include all the code you have, but if you don't you would at least have to try to debug it yourself.
Also, Qt and standard C++ actually don't go together all to well (sadly). I would recommend you to port your standard c++ functions to Qt. That would make it easier.
Jan
|
|
Source code |
1 2 3 4 5 6 7 8 |
MainWindow::MainWindow()
{
my_classe = new My_class(this);
setCentralWidget(my_class);
add_flie= new QToolButton(this);
add_file->setGeometry(QRect(10, 10, 31, 31));
add_file->setText(QApplication::translate("MainWindow", "Add", 0, QApplication::UnicodeUTF8));
connect(add_O, SIGNAL(clicked()),my_classe, SLOT(get_filename()));
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
void My_class::get_and_read_file()
{
QString filename = get_filename();
read_file(filename);
}
QString My_class::get_filename()
{
QString fichier = QFileDialog::getOpenFileName(this, "Ouvrir un fichier", QString(), "ViconFormat (*.c3d)");
QMessageBox::information(this, "Fichier", "Vous avez sélectionné :\n" + fichier);
return fichier;
}
void My_class::read_file(QString fname)
{
my_file=fname.toStdString().c_str();
infile=fopen( my_file,"rb+");
|
|
|
Source code |
1 |
infile=fopen( my_file,"rb+"); |
|
|
Source code |
1 |
infile=fopen( "filename.obj,"rb+"); |
|
|
Source code |
1 |
infile=fopen("C:\my_project\filename.obj","rb+");
|
|
|
Source code |
1 |
infile=fopen("C:\\my_project\\filename.obj","rb+");
|
This post has been edited 1 times, last edit by "chahd09" (May 12th 2012, 8:34pm)
This post has been edited 1 times, last edit by "Amleto" (May 12th 2012, 8:36pm)
|
|
Source code |
1 |
infile=fopen("C:\my_project\filename.obj","rb+");
|
|
|
Source code |
1 |
infile=fopen("C:\\my_project\\filename.obj","rb+");
|
Quoted
it show me now the QFileDialog
because i make get_file as slot
but
it show me the QFileDialog just when i run the program before i see the gui ,not when i clic on the button
in the button i make
![]()
Source code
1 connect(add_file, SIGNAL(clicked()),my_class, SLOT(get_filename()));
What? Qt is written in C++! How do they not go together?