Results 1 to 3 of 3

Thread: [SOLVED] QDeclarativeView mousearea and mouseEvents problems.

  1. #1
    Join Date
    Jul 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question [SOLVED] QDeclarativeView mousearea and mouseEvents problems.

    Hi all!

    I photoshopped a custom user interface for a application i want to bring to life someday primarily for the windows platform. It has a custom titlebar with custom buttons and i designed tree-state windows actions buttons for closing, minimizing and maximazing.

    First off: would you advice against using QML for this, or is that exactly what QML could be used for?

    The problem I'm striving with is mouse-events. I must have done something wrong because when I implement my QML-file (witch work as expected in the qmlviewer) in the QDecalarativeView it doesn't handle mouse-events at all (no hover, click, or anything realy).
    I also would preferably need the mouseevents that arent handled in my qml-file to propagate eighter to a subclassed QDeclarativeView (in c++) or all the way up to my QMainWindow::mousePressEvent(..). So that I can implement moving the window and resizing it.

    Has anybody got any ideas for me? I'll be happy to look myself, I'm just kinda stuck right now. A point in the right direction would go a long way

    Thanks!

    EDIT:

    Okay so I ended up sub-classing the QDeclarativeView and using its mouseEvent functions (also calling QDecalarativeView::mouseXEvent(event); every time to have the qml work aswell) to implement moving and resizing functionality.

    Then I used a normal QWidget sub-classed class to set the titlebar together with the rest of the content and complete the custom window.

    Thanks for the help viulskiez.
    Last edited by acidr; 16th July 2011 at 15:35.

  2. #2
    Join Date
    Jul 2010
    Location
    Indonesia
    Posts
    83
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: QDeclarativeView mousearea and mouseEvents problems.

    Quote Originally Posted by acidr View Post
    I photoshopped a custom user interface for a application i want to bring to life someday primarily for the windows platform. It has a custom titlebar with custom buttons and i designed tree-state windows actions buttons for closing, minimizing and maximazing.

    First off: would you advice against using QML for this, or is that exactly what QML could be used for?

    I also would preferably need the mouseevents that arent handled in my qml-file to propagate eighter to a subclassed QDeclarativeView (in c++) or all the way up to my QMainWindow::mousePressEvent(..). So that I can implement moving the window and resizing it.
    So you need a custom user interface and the main window must at least movable, resizeable, can be minimized, maximized and closed? I suggest to subclass Qwidget for this purpose then reimplement paintEvent, mousePressEvent, mouseReleaseEvent and mouseMoveEvent. And when you really need QDeclarativeView, you can put it inside the custom widget. It's mean I use composition, not inheritance... But you can also inherit your custom widget from QDeclarativeView like in QmlApplicationViewer.
    ~ We are nothing in this universe ~

  3. #3
    Join Date
    Jul 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDeclarativeView mousearea and mouseEvents problems.

    Thanks for the answer. I am already able to show a window almost as I want it to look. I have a vertical grid with the qdeclarativeview being the titlebar and next theres a horizontal grid that contains the rest of my widgets.

    You might be right that it would be better to reimplement it in a fresh qwidget. But I just don't understand why I cant record any mouseEvents. (even though I can see the titlebar it's non-responsive and dead)


    Added after 9 minutes:


    Okey so I tried just running my QML in a QDeclarativeView alone, that worked fine. I'll try something more substantial (sub-classing it and using it as my main window).
    Thanks
    Last edited by acidr; 16th July 2011 at 13:39.

Similar Threads

  1. Using QDeclarativeView::Show()
    By proj_symbian in forum Qt Quick
    Replies: 17
    Last Post: 30th May 2011, 20:26
  2. Replies: 2
    Last Post: 9th May 2011, 03:04
  3. Problem with MouseArea element
    By chiru in forum Qt Quick
    Replies: 1
    Last Post: 27th November 2010, 01:23
  4. QTableWidget mouseEvents
    By QAir in forum Qt Programming
    Replies: 6
    Last Post: 28th July 2009, 17:11
  5. qwt mouseEvents
    By halberdier83 in forum Qwt
    Replies: 7
    Last Post: 22nd April 2009, 13:37

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.