Results 1 to 10 of 10

Thread: Promote to Custom Widget makes the widget disappear !

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2006
    Posts
    20
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Promote to Custom Widget makes the widget disappear !

    Hi,
    I want to be able to do drag & drop on a QListWidget, so I chose to subclass it. To do so, in Designer I selected it and clicked "Promote to custom widget", I named the new class FileList. I also created filelist.h, which I post there :
    Qt Code:
    1. #include <QtGui>
    2.  
    3. class FileList : public QListWidget {
    4. Q_OBJECT
    5.  
    6. public:
    7. FileList (QWidget *parent = 0);
    8. void dragEnterEvent (QDragEnterEvent *event);
    9. void dropEvent (QDropEvent *event);
    10. };
    To copy to clipboard, switch view to plain text mode 

    I also created filelist.cpp, to implement drag & drop functions :
    Qt Code:
    1. #include "filelist.h"
    2.  
    3. FileList::FileList (QWidget *parent) : QListWidget(parent) {
    4. }
    5.  
    6. void FileList::dragEnterEvent (QDragEnterEvent *event) {
    7. if(event->mimeData()->hasFormat("text/uri-list"))
    8. event->acceptProposedAction();
    9. }
    10.  
    11. void FileList::dropEvent (QDropEvent *event) {
    12. qWarning(event->mimeData()->text().toAscii());
    13. }
    To copy to clipboard, switch view to plain text mode 

    The problem is, in Designer preview, or in the final binary, the list does not appear anymore... Any clue ?

  2. The following user says thank you to madcat for this useful post:

    MurDoK (29th April 2007)

Similar Threads

  1. QwtPlot - promote to custom widget
    By MrGarbage in forum Qwt
    Replies: 7
    Last Post: 10th February 2011, 10:12
  2. Custom widget
    By zorro68 in forum Qt Programming
    Replies: 7
    Last Post: 28th January 2008, 14:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.