[Solved] overloading dropEvent
-
I am working on a simple window app. I have two qlistwidgets and I want to overload the dropEvent for one of them.
@namespace Ui {
class MainWindow;
}class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();protected:
void changeEvent(QEvent *e);
virtual void dropEvent(QDropEvent *e);private:
Ui::MainWindow *ui;private slots:
void on_createString_clicked();
};@Ui::MainWindow *ui; is the main class that contains all the widgets. the ui_window.h file is generated by qtcreator.
All the examples that I have seen put the function void dropEvent in the "your class" header file(the code above).
I have tried this but it does not seem to work. It seems like I am doing this a level to high, but I don't know where to put it since you should not edit the ui_window.h because it will get overwritten the next time you do something in qtcreator.
Any help would be great.
Thanks -
I have created a new class and promoted my QListWidget to the new class but now it does not appear when I run the program. It is viewable in UI designer and the following code is generated.
@
CustomProtocol = new CustomListWidget(centralWidget);
CustomProtocol->setObjectName(QString::fromUtf8("CustomProtocol"));
CustomProtocol->setGeometry(QRect(440, 20, 300, 275));
CustomProtocol->setDragEnabled(true);
CustomProtocol->setDragDropMode(QAbstractItemView::DragDrop);
CustomProtocol->setDefaultDropAction(Qt::MoveAction);
@Does the constructor the new class need anything? It is currently blank.
Thanks,
-
hope "this wiki page":http://developer.qt.nokia.com/wiki/Custom_QListWidget helps