Results 1 to 20 of 20

Thread: Flickering mouse pointer

  1. #1
    Join Date
    Mar 2010
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Flickering mouse pointer

    An extremely simple text editor accepts external file drop changing its title:
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6. setAcceptDrops(true);
    7. }
    8.  
    9. void MainWindow::dragEnterEvent(QDragEnterEvent *event)
    10. {
    11. event->accept();
    12. }
    13.  
    14. void MainWindow::dragMoveEvent(QDragMoveEvent *event)
    15. {
    16. event->accept();
    17. }
    18.  
    19. void MainWindow::dropEvent(QDropEvent *event)
    20. {
    21. if (event->mimeData()->hasFormat("text/uri-list")) {
    22. QList<QUrl> urls = event->mimeData()->urls();
    23. if (urls.isEmpty())
    24. return;
    25. QString fileName = urls.first().toLocalFile();
    26. if (fileName.isEmpty())
    27. return;
    28. setWindowTitle(tr("%1 - %2").arg(fileName).arg(tr("Drag File")));
    29. }
    30. }
    To copy to clipboard, switch view to plain text mode 
    MainWindow has just one widget, textEdit, defined by:
    Qt Code:
    1. MyTextEdit::MyTextEdit(QWidget *parent)
    2. : QTextEdit(parent)
    3. {
    4. setAcceptDrops(true);
    5. }
    6.  
    7. void MyTextEdit::dragEnterEvent(QDragEnterEvent *e)
    8. {
    9. if (e->source()) {
    10. if (e->source() == viewport()) {
    11. e->accept();
    12. }
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 
    textEdit accepts only "self" drops, so inserted text can then be moved or copied.
    What is the reason of the pointer flickering? How can i remove it?
    Thanks.
    Last edited by guiQt; 31st August 2010 at 17:25.

  2. #2
    Join Date
    Mar 2010
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Flickering mouse pointer

    Bump

  3. #3
    Join Date
    Mar 2010
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Flickering mouse pointer

    Looking for an answer

  4. #4
    Join Date
    Mar 2010
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Flickering mouse pointer

    Rebump

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Flickering mouse pointer

    I can't see any problem in your code, so can you please provide a minimal compilable example reproducing your problem.

  6. #6
    Join Date
    Mar 2010
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Flickering mouse pointer

    droptest example
    Problem shows up when you try to move/copy any entered word by dragging/Ctrl+dragging.
    Attached Files Attached Files
    Last edited by guiQt; 12th September 2010 at 09:41.

  7. #7
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Flickering mouse pointer

    Can't reproduce it here on Mac. Where did you see it, Linux (which) or Windows or both?

  8. #8
    Join Date
    Mar 2010
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Flickering mouse pointer

    Ubuntu 10.04. Not tested on Windows.

  9. #9
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Flickering mouse pointer

    I have tested on kubuntu 10.4 and there is no "flicker", and can test on ubuntu, but a little bit later

    LE:tested on ubuntu 10.4 and didn't flicker.
    Last edited by Zlatomir; 12th September 2010 at 11:43.

  10. #10
    Join Date
    Mar 2010
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Flickering mouse pointer

    Well, I'm pleased with the correctness of the code, but astonished with the configuration of my system.
    Can't think about anything correlated...

  11. #11
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Flickering mouse pointer

    Try playing with performance settings.

    - Update your graphics driver
    - Try disabling some desktop effects

  12. #12
    Join Date
    Mar 2010
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Flickering mouse pointer

    Tried playing with some Compiz effects, following tbscope's hint.
    However I think it's not a performance matter.
    The problem seems to be correlated to MyTextEdit widget itself. To prove that, I added a second QTextEdit to MainWindow: flicker shows up only when dragging over MyTextEdit.
    P.S. Short video included
    Attached Files Attached Files
    Last edited by guiQt; 12th September 2010 at 16:34.

  13. #13
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Flickering mouse pointer

    Ok, on my console I get
    Qt: Internal error: WH0A, unexpected condition reached
    ? Not sure what goes wrong here.

  14. #14
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Flickering mouse pointer

    Ehm, I found it: you have forgot to forward the drag to the base class:
    Qt Code:
    1. void MyTextEdit::dragEnterEvent(QDragEnterEvent *e)
    2. {
    3. if (e->source()) {
    4. if (e->source() == viewport()) {
    5. e->accept();
    6. }
    7. }
    8. QTextEdit::dragEnterEvent(e);
    9. }
    To copy to clipboard, switch view to plain text mode 
    Also use the Q_OBJECT macro in your own text edit class.

  15. #15
    Join Date
    Mar 2010
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Flickering mouse pointer

    The solution proposed by Lykurg removes the flicker, but the drag is not forwarded to the MainWindow when text editor accepts external file drop.
    So the code that meets initial requests is:
    Qt Code:
    1. void MyTextEdit::dragEnterEvent(QDragEnterEvent *e)
    2. {
    3. if (e->source()) {
    4. if (e->source() == viewport()) {
    5. e->accept();
    6. QTextEdit::dragEnterEvent(e);
    7. return;
    8. }
    9. }
    10. e->ignore();
    11. }
    To copy to clipboard, switch view to plain text mode 

  16. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Flickering mouse pointer

    Hmm.... You mean you don't want the text editor to accept any drags apart the ones that originated in itself? Some strange text editor
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  17. #17
    Join Date
    Mar 2010
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Flickering mouse pointer

    It's a pure theoretical (and trivial, obviously) case (described above in detail).
    The final goal is to develop a lot more complex custom widget (MyTextEdit class with extended QTextEdit functionalities) that besides accepting normal drag and drop originated in itself, it sends external drops to its parent.
    This way it's reusable: each application using MyTextEdit class is allowed to manage external drops in its own way.

  18. #18
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Flickering mouse pointer

    I would still want to be able to drop some text snippet into the text editor without having to implement that in the parent/subclass of the editor... Especially if that was part of the original behaviour of the text editor.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  19. #19
    Join Date
    Mar 2010
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Flickering mouse pointer

    Quote Originally Posted by wysota View Post
    I would still want to be able to drop some text snippet into the text editor without having to implement that in the parent/subclass of the editor...
    Perhaps you'll use YourTextEdit class

  20. #20
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Flickering mouse pointer

    Perhaps I would simply block only those events I explicitly don't want instead of blocking everything which is not what I am interested in at the moment.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Is it possible to hide mouse pointer??
    By webquinty in forum Newbie
    Replies: 5
    Last Post: 24th November 2009, 14:57
  2. changing mouse pointer
    By bhogasena in forum Qt Programming
    Replies: 2
    Last Post: 29th January 2009, 15:57
  3. free mouse pointer
    By raflegan in forum Qt Programming
    Replies: 1
    Last Post: 1st October 2008, 14:11
  4. How can I hide the mouse pointer?
    By dimaz in forum Qt Programming
    Replies: 2
    Last Post: 22nd August 2008, 19:08
  5. Scribble example: problem with mouse pointer
    By srinath1986 in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 24th February 2008, 13:13

Tags for this Thread

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.