Results 1 to 5 of 5

Thread: odd failure while adding custom widgets to QDockWidget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2008
    Posts
    5

    Default odd failure while adding custom widgets to QDockWidget

    I want to add several widgets to a single dockwidget.
    As the QDockWidget owns no "addWidget" function, I managed to add a widgetForDock widget to it using "setWidget" function, and make other widgets children of the widgetForDock.

    eg:
    Qt Code:
    1. dockWidget->setWidget(widgetForDock);
    To copy to clipboard, switch view to plain text mode 

    It works well, when I make it through toward the Qt widgets, such as QLineEdit and QGroupBox. However, when I add my own object of class HistogramView, derived from QWidget, it fails to show.

    eg: fail
    Qt Code:
    1. QVBoxLayout *layout = new QVBoxLayout(widgetForDock);
    2. HistogramView *histView = new HistogramView();
    3. layout->addWidget(histView);
    4.  
    5. class HistogramView : public QWidget
    6. {
    7. ...
    8. public:
    9. HistogramPlotter *histPlotter;
    10. QWidget *widget;
    11. }
    To copy to clipboard, switch view to plain text mode 

    The even odder thing is that, when I add the object histView itselft to the dockWidget, it fails, while the public members (histPlotter and widget) are added to it, it works well!

    eg: works!
    Qt Code:
    1. layout->addWidget(histView->histPlotter);
    2. layout->addWidget(histView->widget);
    To copy to clipboard, switch view to plain text mode 
    The HistogramPlotter is a cumter widget, also derived from the QWidget, just as its owner object do.
    Last edited by jpn; 4th December 2008 at 19:45. Reason: missing [code] tags

Similar Threads

  1. Replies: 2
    Last Post: 16th May 2008, 14:39
  2. picking geometry in qt custom widgets
    By notsonerdysunny in forum Qt Programming
    Replies: 2
    Last Post: 17th July 2007, 23:01

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.