Results 1 to 4 of 4

Thread: paint central widget of a QMainWindow???

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: paint central widget of a QMainWindow???

    Quote Originally Posted by Shuchi Agrawal View Post
    so for this do i need QStackedWidget ? or simply a obj. of QWidget n set it as central widget???
    The central widget can be anything inheriting from QWidget, but I think Qt Designer restricts it to be a QWidget. Just create any custom widget, reimplement the paintEvent(), add corresponding widget in the Designer and promote it.

    As I have said previously:
    Quote Originally Posted by jpn View Post
    Override QWidget::paintEvent() for the widget you want to paint on and use QPainter to draw the line. For example, if you want to paint on the central widget in a main window, you must reimplement the paintEvent() for the central widget, not for the main window.
    So, in another words.
    WRONG: "void MyMainWindow::paintEvent(QPaintEvent* event)"
    CORRECT: "void MyCentralWidget::paintEvent(QPaintEvent* event)"
    J-P Nurmi

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

    Shuchi Agrawal (18th January 2007)

Similar Threads

  1. Replies: 4
    Last Post: 25th August 2014, 19:05
  2. Pin/Unpin Dock Widget
    By charlesD in forum Newbie
    Replies: 1
    Last Post: 21st June 2006, 07:57
  3. Central Widget of QMainWindow
    By sumsin in forum Qt Programming
    Replies: 3
    Last Post: 13th March 2006, 19:32
  4. [Qt 4.1.0] Split a widget on demand
    By Townk in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2006, 15:16
  5. QMainWindow and its QDockWidget
    By Promethee in forum Qt Programming
    Replies: 2
    Last Post: 13th January 2006, 21:42

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.