Results 1 to 3 of 3

Thread: I want to add something that looks like a QGridLayout to a QDockWidget with setWidget

  1. #1
    Join Date
    Feb 2008
    Posts
    36
    Thanks
    4

    Default I want to add something that looks like a QGridLayout to a QDockWidget with setWidget

    Hi all,

    Unfortunately it's not possible to add a QGridLayout* to a QDockWidget in a QMainWindow. It is possible to add one QLineEdit or one QLabel with QDockWidget::setWidget(QWidget *widget).

    It's possible to add a QTextEdit which is able to show file contens to the DockWidget with setWidget, but then I have to write all the QLinEdit/QLabels to file which is inconvenient since the QLineEdits variables will change a lot of times during program execution.

    My question is how can I add several QLineEdit/QLabels to the same DockWidgetArea?
    Any help is deeply appreciated!
    Thanks

  2. #2
    Join Date
    Feb 2008
    Posts
    98
    Thanks
    2
    Thanked 24 Times in 24 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I want to add something that looks like a QGridLayout to a QDockWidget with setWi

    Can't you just create a blank widget, set it as the dockwidget's widget and then assign it the layout you want?

    Qt Code:
    1. QWidget *widget = new QWidget(this);
    2. dockWidget->setWidget(widget);
    3.  
    4. QGridLayout *layout = new QGridLayout(widget);
    5. // add widgets to the layout
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to victor.fernandez for this useful post:

    gQt (24th August 2009)

  4. #3
    Join Date
    Feb 2008
    Posts
    36
    Thanks
    4

    Default Re: I want to add something that looks like a QGridLayout to a QDockWidget with setWi

    That worked
    Thanks, That blank widget solved the problem!

Similar Threads

  1. QPushButton in QDockWidget loses stylesheet
    By martinb0820 in forum Qt Programming
    Replies: 5
    Last Post: 22nd June 2009, 18:23
  2. QDockWidget - dynamic size
    By ttvo in forum Qt Programming
    Replies: 3
    Last Post: 12th June 2009, 07:07
  3. QDockWidget magically disapear
    By 1111 in forum Qt Programming
    Replies: 1
    Last Post: 29th January 2009, 11:44
  4. Qt 3.3 QGridLayout
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 23rd February 2007, 17:40
  5. Replies: 8
    Last Post: 4th February 2007, 00: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.