Results 1 to 19 of 19

Thread: draing plugin on parent widget in qt-designer 4.5.3

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2010
    Posts
    13
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default draing plugin on parent widget in qt-designer 4.5.3

    I created plugin which draws cross on parent widget. In constructor:
    Qt Code:
    1. mAim=new HmiAim(this->parentWidget());
    To copy to clipboard, switch view to plain text mode 

    In header(description of class):

    ...
    Qt Code:
    1. HmiAim *mAim;
    2. }
    3. class HmiAim:public QWidget
    4. {
    5. Q_OBJECT
    6. protected:
    7. virtual void paintEvent(QPaintEvent *event);
    8. };
    To copy to clipboard, switch view to plain text mode 

    And paint event:

    Qt Code:
    1. void
    2. HmiAim::paintEvent(QPaintEvent *event)
    3. {
    4. QPainter painter(this);
    5. QPen pen;
    6. pen.setColor(QColor (225,104,15));
    7. pen.setWidth(2);
    8. painter.setPen(pen);
    9. painter.drawLine(0,15,30, 15);
    10. painter.drawLine(15,0, 15, 30);
    11. }
    To copy to clipboard, switch view to plain text mode 

    It works everywhere ,exept designer(works in preview,in projects). It even works in designer if I save UI-file with this plugin and open it - cross will be and in designer mode for saved plagins, but not for new added.
    Last edited by wysota; 12th January 2010 at 16:44.

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

    Default Re: draing plugin on parent widget in qt-designer 4.5.3

    Did you implement sizeHint() for your widget?
    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
    Jan 2010
    Posts
    13
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: draing plugin on parent widget in qt-designer 4.5.3

    Quote Originally Posted by wysota View Post
    Did you implement sizeHint() for your widget?
    No, but how sizeHint can help?

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

    Default Re: draing plugin on parent widget in qt-designer 4.5.3

    If your widget is of size (0,0) then it may be hard to see it. I don't know if that's the problem here but you should definitely implement sizeHint() and rule this one out.
    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
    Jan 2010
    Posts
    13
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: draing plugin on parent widget in qt-designer 4.5.3

    Quote Originally Posted by wysota View Post
    If your widget is of size (0,0) then it may be hard to see it. I don't know if that's the problem here but you should definitely implement sizeHint() and rule this one out.
    No - I set fixed size for this widget. And there is part which always drawn, but it draws for plugin - not for parent

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

    Default Re: draing plugin on parent widget in qt-designer 4.5.3

    You are drawing on the widget not on its parent in your code. Right?
    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.


  7. #7
    Join Date
    Jan 2010
    Posts
    13
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: draing plugin on parent widget in qt-designer 4.5.3

    Quote Originally Posted by wysota View Post
    You are drawing on the widget not on its parent in your code. Right?
    One part is drawing on widget(always work) and one on parent(always, exept new plugins in QT-designer) - there is two paint events for it.

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

    Default Re: draing plugin on parent widget in qt-designer 4.5.3

    Two paint events? How come? A widget can't draw on other widgets using paint events. It can only install an event filter.
    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.


  9. #9
    Join Date
    Jan 2010
    Posts
    13
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: draing plugin on parent widget in qt-designer 4.5.3

    Quote Originally Posted by wysota View Post
    Two paint events? How come? A widget can't draw on other widgets using paint events. It can only install an event filter.
    There is 2 classes in plugin and 2 paint events for them .

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

    Default Re: draing plugin on parent widget in qt-designer 4.5.3

    Please show us the code.
    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.


  11. #11
    Join Date
    Jan 2010
    Posts
    13
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: draing plugin on parent widget in qt-designer 4.5.3

    Quote Originally Posted by wysota View Post
    Please show us the code.
    Ok - files are attached .
    Attached Files Attached Files

Similar Threads

  1. Designer plugin widget property not recognized
    By janus in forum Qt Programming
    Replies: 7
    Last Post: 14th April 2009, 21:26
  2. Replies: 4
    Last Post: 9th August 2007, 08:20
  3. Replies: 1
    Last Post: 22nd January 2007, 12:13
  4. Size of a plugin widget in designer
    By high_flyer in forum Qt Programming
    Replies: 4
    Last Post: 28th February 2006, 13:29
  5. Managing widget plugin in Qt Designer
    By yellowmat in forum Newbie
    Replies: 8
    Last Post: 31st January 2006, 09:58

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.