Results 1 to 14 of 14

Thread: How to draw QGraphicsItem at the same location?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2011
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to draw QGraphicsItem at the same location?

    Hi,

    I have the same problem. I have an Item that must stay always on top edge of an viewport. I want try whit a widget on my viewport but I have some problem.

    Qt Code:
    1. void CMCanvasManager::createMenu(QWidget *canvas_parent)
    2. {
    3. QWidget *w=new QWidget(canvas_parent, Qt::Popup | Qt::WindowStaysOnTopHint);
    4. w->setGeometry(100, 100, 100, 100);
    5. w->setMaximumSize(100,100);
    6. w->setMinimumSize(100,100);
    7. w->setFocusPolicy(Qt::NoFocus);
    8. w->show();
    9. }
    To copy to clipboard, switch view to plain text mode 

    Whit the code above I expect that my popup widget stay at 100,100 respect the parent geometry, but this does not happen. The widget appear at 100,100 respect the desktop, olso if I click on viewport the popup disappear. Any advice?

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

    Default Re: How to draw QGraphicsItem at the same location?

    What is canvas_parent? And why are you setting those flags in the constructor?
    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.


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

    Default Re: How to draw QGraphicsItem at the same location?

    canvas_parent is the widget that contain my custom QGraphicsView class, and I have set the flags in the costructo because I thought it was the best way to do it. I think that I have wrong all.
    I am proceeding to attempts because I did not quite clear how the widgets work. Sorry.. Councils do what I described? Thank you!

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

    Default Re: How to draw QGraphicsItem at the same location?

    Quote Originally Posted by Zikoel View Post
    canvas_parent is the widget that contain my custom QGraphicsView class
    So how is this supposed to work? Do you understand the relationship between a widget and its parent?
    I think that I have wrong all.
    I think so too

    I am proceeding to attempts because I did not quite clear how the widgets work. Sorry.. Councils do what I described? Thank you!
    Looking at my earlier explanation, I write that you should position the widget on the viewport. To do that the widget needs to be a child of the viewport, not of an arbitrary widget.

    If you have no idea about how things work, kindly please consider posting in the Newbie section and please be very explicit about what you are doing, it will save you a lot of time.
    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.


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

    Default Re: How to draw QGraphicsItem at the same location?

    When I say "I am proceeding to attempts because I did not quite clear how the widgets work" I mean that I do not know the widget, but I work with Qt at least a year ;D.

    I have modified the code in this mode:

    Qt Code:
    1. void CMCanvas::createMenu(){
    2. m_menu_canvas=new QWidget();
    3. m_menu_canvas->setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
    4. m_menu_canvas->setGeometry(100, 100, 100, 100);
    5. m_menu_canvas->setMaximumSize(100,100);
    6. m_menu_canvas->setMinimumSize(100,100);
    7. m_menu_canvas->show();
    8. }
    9. void CMCanvas::destroyMenu(){
    10. m_menu_canvas->close();
    11. }
    To copy to clipboard, switch view to plain text mode 

    The two metod is inside my custom class of QGraphicsView, but I do not know how to anchor the two windows.

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

    Default Re: How to draw QGraphicsItem at the same location?

    Please get familiar with the concept or parent-child relationship between widgets. And I don't mean Qt but rather the GUI architecture currently used on desktop systems. So far you are trying to stack two top-level windows on top of each other which is unlikely to do what you want. Of course unless you want something else than what this thread is about.
    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. Replies: 10
    Last Post: 10th February 2011, 23:31
  2. Replies: 7
    Last Post: 29th November 2010, 19:20
  3. Bitmap Memory location to read and draw in Qt
    By augusbas in forum Qt Programming
    Replies: 1
    Last Post: 2nd September 2010, 21:21
  4. Replies: 0
    Last Post: 16th August 2009, 17:46
  5. Location of QGraphicItem!!
    By rachana in forum Qt Programming
    Replies: 2
    Last Post: 2nd February 2007, 21:20

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
  •  
Qt is a trademark of The Qt Company.