| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 4 | |
Hi, I designed the ui of what I intend to be a dock widget that will dock on the rhs of my main window. I designed it using designer and it looks and functions as expected. Now I subclass from the ui class generated thus ... #include "ui_toolDock.h" #include <QDockWidget> class toolDock : public QDockWidget, public Ui::toolDock; and currently the only thing I have is setupUI(this) in the constructor. This does not work as expected, with my dock hidden, and the layout messed up. In adition it does not resize if I resize the dock. Also I get a runtime warning ... "Attempting to add QLayout "" to toolDock "toolDock", which already has a layout." what am I doing wrong ? I have an earlier version of a class derived from QDockWidget and the ui stuff added manually and that worked as expected. thanks, ~Hari -- [ signature omitted ]
Hari Sundar wrote: > [...] > This does not work as expected, with my dock hidden, and the > layout messed up. In adition it does not resize if I resize > the dock. Also I get a runtime warning ... > > "Attempting to add QLayout "" to toolDock "toolDock", which > already has a layout." Shot in the dark: Have you tried to destroy the layout that seems to be there already before calling setupUi()? Andre' -- [ signature omitted ]
I don't know what layout it's complaining about. I do not apply any layout to this widget .. or the parent for that case ... since all I do is set a central widget .. and then add this as a dock widget ... I tried to create a frame in the toolDock constructor .. and then call setupUI(frame) instead ... this works better .. in that the whole UI is visible .. but hidden to start with .. i.e., width =0 .. and if I resize the dock .. I can see it .. but it doesn't resize well .. basically the UI size seems to be fixed ... and I only seem to be able to change the size of the frame to make it hold the UI ... ~Hari On 8/18/06, Andrà PÃnitz <andre@xxxxxxx> wrote: > > Hari Sundar wrote: > > [...] > > This does not work as expected, with my dock hidden, and the > > layout messed up. In adition it does not resize if I resize > > the dock. Also I get a runtime warning ... > > > > "Attempting to add QLayout "" to toolDock "toolDock", which > > already has a layout." > > Shot in the dark: Have you tried to destroy the layout that > seems to be there already before calling setupUi()? > > Andre' > > -- > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with > "unsubscribe" in the subject or the body. > List archive and information: http://lists.trolltech.com/qt-interest/ > > -- [ signature omitted ]
Help ... I just can't figure this out ... For some strange reason QDockWidget behaves in a very strange way .... I am able to get the scheme to work ... if ... 1. I wrap my UI class with one derived from QDialog, in addition to UI::class ... 2. within mainwindow .. I create an empty QDockWidget ... and call setWidget on this ... This is not what I want ideally .. since I want to connect signals/slots .. and it will be cleaner if done directly from the derived class which should be the dock ... In addition ... it resizes the UI to be too wide even if I set the sizePolicy to be fixed ... This never happens when I use other classes ... why only with QDockWidget ? thanks, ~Hari On 8/18/06, Hari Sundar <hsundar@xxxxxxxxx> wrote: > > I don't know what layout it's complaining about. I do not apply any layout > to this widget .. or the parent for that case ... > > since all I do is set a central widget .. and then add this as a dock > widget ... I tried to create a frame in the toolDock constructor .. and then > call setupUI(frame) instead ... this works better .. in that the whole UI > is visible .. but hidden to start with .. i.e., width =0 .. and if I > resize the dock .. I can see it .. but it doesn't resize well .. basically > the UI size seems to be fixed ... and I only seem to be able to change the > size of the frame to make it hold the UI ... > > ~Hari > > > On 8/18/06, Andrà PÃnitz <andre@xxxxxxx> wrote: > > > > Hari Sundar wrote: > > > [...] > > > This does not work as expected, with my dock hidden, and the > > > layout messed up. In adition it does not resize if I resize > > > the dock. Also I get a runtime warning ... > > > > > > "Attempting to add QLayout "" to toolDock "toolDock", which > > > already has a layout." > > > > Shot in the dark: Have you tried to destroy the layout that > > seems to be there already before calling setupUi()? > > > > Andre' > > > > -- > > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with > > "unsubscribe" in the subject or the body. > > List archive and information: http://lists.trolltech.com/qt-interest/ > > > > > > > -- > 1 (215) 662 7501 (w) > 1 (215) 614 0266 (f) > 1 (732) 672 1094 (m) > > http://www.seas.upenn.edu/~hsundar/<http://www.seas.upenn.edu/%7Ehsundar/> > -- [ signature omitted ]
Hari Sundar wrote: > Help ... I just can't figure this out ... For some strange reason > QDockWidget behaves in a very strange way .... I am able to get the scheme > to work ... if ... > > 1. I wrap my UI class with one derived from QDialog, in addition to > UI::class ... > 2. within mainwindow .. I create an empty QDockWidget ... and call > setWidget on this ... > > This is not what I want ideally .. since I want to connect signals/slots > .. and it will be cleaner if done directly from the derived class which > should be the dock ... > > In addition ... it resizes the UI to be too wide even if I set the > sizePolicy to be fixed ... > > This never happens when I use other classes ... why only with QDockWidget > ? You seem to be describing all the different ways you tried to work around the original problem, and it's difficult to say what's happening or recommend a solution. Can you post the .ui file and a minimal code example that shows what you are doing, or at least a code snippet? -- [ signature omitted ]
Hi,
I am attaching the ui file .. and the most simple derived class from this
... I have tried this with the dockwidgets example by simply adding the
following 2 lines to the createDockWindows() functions ...
// my test ...
testDock *mydock = new testDock("Test", this);
addDockWidget(Qt::RightDockWidgetArea, mydock);
As you can see .. it does not render properly ....
thanks,
~Hari
On 8/21/06, David Boddie <dboddie@xxxxxxxxxxxxx> wrote:
>
> Hari Sundar wrote:
>
> > Help ... I just can't figure this out ... For some strange reason
> > QDockWidget behaves in a very strange way .... I am able to get the
> scheme
> > to work ... if ...
> >
> > 1. I wrap my UI class with one derived from QDialog, in addition to
> > UI::class ...
> > 2. within mainwindow .. I create an empty QDockWidget ... and call
> > setWidget on this ...
> >
> > This is not what I want ideally .. since I want to connect signals/slots
> > .. and it will be cleaner if done directly from the derived class which
> > should be the dock ...
> >
> > In addition ... it resizes the UI to be too wide even if I set the
> > sizePolicy to be fixed ...
> >
> > This never happens when I use other classes ... why only with
> QDockWidget
> > ?
>
> You seem to be describing all the different ways you tried to work around
> the original problem, and it's difficult to say what's happening or
> recommend a solution. Can you post the .ui file and a minimal code
> example that shows what you are doing, or at least a code snippet?
>
> --
> David Boddie
> Technical Writer, Trolltech ASA
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
--
[ signature omitted ]
Attachment:
dock.png
Description: PNG image
Attachment:
testDock.ui
Description: application/designer
#ifndef TESTDOCK_H
#define TESTDOCK_H
#include "ui_testDock.h"
#include <QDockWidget>
class testDock : public QDockWidget, private Ui::testDock
{
Q_OBJECT
public:
testDock(const QString &name, QWidget * parent = 0, Qt::WFlags f = 0 );
};
#endif
#include "testDock.h"
#include "testDock.h"
testDock::testDock(const QString &name, QWidget * parent, Qt::WFlags f) : QDockWidget(parent, f)
{
setObjectName(name);
// setWindowTitle(name);
setupUi(this);
}
On Monday 21 August 2006 15:53, Hari Sundar wrote:
>
> I am attaching the ui file .. and the most simple derived class from this
> ... I have tried this with the dockwidgets example by simply adding the
> following 2 lines to the createDockWindows() functions ...
>
> // my test ...
> testDock *mydock = new testDock("Test", this);
> addDockWidget(Qt::RightDockWidgetArea, mydock);
>
> As you can see .. it does not render properly ....
OK. I see what you're doing. The widget you created in Qt Designer is
derived from QWidget, and you have given it a layout and child widgets.
The code written by uic for the form includes code to set the layout so,
if you inherit from QDockWidget in your "testDock" subclass, the setupUi()
will try to add your layout to the one that QDockWidget already provides.
Instead of doing this, why don't you construct a QWidget (or use the
subclassing approach with a QWidget), set up the user interface with
setupUI(), and set that widget on a newly constructed dock widget?
QWidget *widget = new QWidget;
Ui::testDock ui;
ui.setupUi(widget);
QDockWidget mydock = new QDockWidget("Test", this);
dockWidget->setWidget(widget);
addDockWidget(Qt::RightDockWidgetArea, mydock);
I'm slightly confused as to why you want to create the dock widget
separately from your main window. Nonetheless, this should do more or
less what you want.
--
[ signature omitted ]