Hello,
this may sound like a subject for pure C++ Programming forum but I ilustrate problem on qt4/ui program, so I deciced to rather put it here.
I have form designed in designer, it contains only treeWidget which is promoted to custom widget to add drag and drop capabilty.
My question is how to access myAppList defined in myApp.h from qmytreewidget.cpp ? I use Qt 4.2.0-tp1 opensource, Windows 2000, mingw.
Thanks for any suggestions.
Whole app is zipped in attachement, most interesting parts:
myApp.h
#ifndef MYAPP_H
#define MYAPP_H
#include "ui_form.h"
class myApp
: public QWidget,
private Ui
::myAppDLG{
Q_OBJECT
public:
myApp();
// i want to access this from qmytreewidget.cpp, line 26
private:
Ui::myAppDLG ui;
};
#endif
#ifndef MYAPP_H
#define MYAPP_H
#include "ui_form.h"
class myApp : public QWidget, private Ui::myAppDLG
{
Q_OBJECT
public:
myApp();
// i want to access this from qmytreewidget.cpp, line 26
QStringList myAppList;
private:
Ui::myAppDLG ui;
};
#endif
To copy to clipboard, switch view to plain text mode
qmytreewidget.cpp
#include <QtGui>
#include "qmytreewidget.h"
#include "myApp.h"
QMyTreeWidget
::QMyTreeWidget(QWidget *parent
){
}
{
urlList = data->urls();
foreach
(QUrl url, urlList
) {
item->setText(0, url.toLocalFile());
// i want to access myAppList, defined in myApp.h
// what is the best way to do it ?
myAppList.append(url.toLocalFile()); // this of course doesn't work, just to clear what a want to do
}
return true;
}
qstrList.append("text/uri-list");
return qstrList;
}
#include <QtGui>
#include "qmytreewidget.h"
#include "myApp.h"
QMyTreeWidget::QMyTreeWidget(QWidget *parent)
: QTreeWidget(parent)
{
}
bool QMyTreeWidget::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action)
{
QTreeWidgetItem *item;
QList <QUrl> urlList;
urlList = data->urls();
foreach(QUrl url, urlList)
{
item = new QTreeWidgetItem(this);
item->setText(0, url.toLocalFile());
// i want to access myAppList, defined in myApp.h
// what is the best way to do it ?
myAppList.append(url.toLocalFile()); // this of course doesn't work, just to clear what a want to do
}
return true;
}
QStringList QMyTreeWidget::mimeTypes () const {
QStringList qstrList;
qstrList.append("text/uri-list");
return qstrList;
}
To copy to clipboard, switch view to plain text mode
Bookmarks