Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, December 2007
QDockWidget and resizing.


Message 1 in thread

Hello,

I have a QDockWidget and I would like that when I resize my application
( in height ), the QDockWidget increase and not the main Widget.

My (hideous) code does the following:

dockPL = new QDockWidget( qtr( "Playlist" ), this );
dockPL->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );

playlistWidget = new PlaylistWidget( p_intf, settings );
playlistWidget->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
dockPL->setWidget( playlistWidget );

addDockWidget( Qt::BottomDockWidgetArea, dockPL );

QWidget *main = new QWidget;
setCentralWidget( main );

main->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );


But when I resize, it doesn't increase the dock, but only the main
widget...
What am I doing wrong ?

Full code:
https://trac.videolan.org/vlc/browser/trunk/modules/gui/qt4/main_interface.cpp
and
https://trac.videolan.org/vlc/browser/trunk/modules/gui/qt4/components/interface_widgets.cpp


btw,
http://www.jbkempf.com/~jb/vlc/VLC-1dec.jpg

Best Regards,

-- 
 [ signature omitted ] 

Message 2 in thread

Just trying to guess:

What you could try: overwrite resizeEvent and tell it to don't resize
horizontally.
http://doc.trolltech.com/4.3/qwidget.html#resizeEvent

Here they talk about dock too.
http://lists.trolltech.com/qt-interest/2007-09/thread00846-0.html

(BTW here's what firefox 3 says when clicking on the trac links.

trac.videolan.org uses an invalid security certificate.
The certificate is not trusted because the issuer certificate is unknown.
(Error code: sec_error_unknown_issuer)

Benjamin.

On Dec 15, 2007 3:46 PM, Jean-Baptiste Kempf <jb@xxxxxxxxxxxx> wrote:
> Hello,
>
> I have a QDockWidget and I would like that when I resize my application
> ( in height ), the QDockWidget increase and not the main Widget.
>
> My (hideous) code does the following:
>
> dockPL = new QDockWidget( qtr( "Playlist" ), this );
> dockPL->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
>
> playlistWidget = new PlaylistWidget( p_intf, settings );
> playlistWidget->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
> dockPL->setWidget( playlistWidget );
>
> addDockWidget( Qt::BottomDockWidgetArea, dockPL );
>
> QWidget *main = new QWidget;
> setCentralWidget( main );
>
> main->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
>
>
> But when I resize, it doesn't increase the dock, but only the main
> widget...
> What am I doing wrong ?
>
> Full code:
> https://trac.videolan.org/vlc/browser/trunk/modules/gui/qt4/main_interface.cpp
> and
> https://trac.videolan.org/vlc/browser/trunk/modules/gui/qt4/components/interface_widgets.cpp
>
>
> btw,
> http://www.jbkempf.com/~jb/vlc/VLC-1dec.jpg
>
> Best Regards,
>
> --
> Jean-Baptiste Kempf
> http://www.jbkempf.com/
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> http://mailman.videolan.org/listinfo/vlc-devel
>

--
 [ signature omitted ] 

Message 3 in thread

On Sun, Dec 16, 2007, Benjamin Sergeant wrote :
> Just trying to guess:
> 
> What you could try: overwrite resizeEvent and tell it to don't resize
> horizontally.
> http://doc.trolltech.com/4.3/qwidget.html#resizeEvent
Ok, this is what I wanted to avoid... :D
Should I do it onmy main application ? on my central widget ?

> On Dec 15, 2007 3:46 PM, Jean-Baptiste Kempf <jb@xxxxxxxxxxxx> wrote:
> > Hello,
> >
> > I have a QDockWidget and I would like that when I resize my application
> > ( in height ), the QDockWidget increase and not the main Widget.
> >
> > My (hideous) code does the following:
> >
> > dockPL = new QDockWidget( qtr( "Playlist" ), this );
> > dockPL->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
> >
> > playlistWidget = new PlaylistWidget( p_intf, settings );
> > playlistWidget->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
> > dockPL->setWidget( playlistWidget );
> >
> > addDockWidget( Qt::BottomDockWidgetArea, dockPL );
> >
> > QWidget *main = new QWidget;
> > setCentralWidget( main );
> >
> > main->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
> >
> >
> > But when I resize, it doesn't increase the dock, but only the main
> > widget...
> > What am I doing wrong ?
> >
> > Full code:
> > https://trac.videolan.org/vlc/browser/trunk/modules/gui/qt4/main_interface.cpp
> > and
> > https://trac.videolan.org/vlc/browser/trunk/modules/gui/qt4/components/interface_widgets.cpp
> >
> >
> > btw,
> > http://www.jbkempf.com/~jb/vlc/VLC-1dec.jpg
> >
> > Best Regards,
> >
> > --
> > Jean-Baptiste Kempf
> > http://www.jbkempf.com/
> > _______________________________________________
> > vlc-devel mailing list
> > To unsubscribe or modify your subscription options:
> > http://mailman.videolan.org/listinfo/vlc-devel
> >
> 
> --
> 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/
Best Regards,

-- 
 [ signature omitted ] 

Message 4 in thread

On Dec 16, 2007 3:09 PM, Benjamin Sergeant <bsergean@xxxxxxxxx> wrote:
> Just trying to guess:
>
> What you could try: overwrite resizeEvent and tell it to don't resize
> horizontally.
> http://doc.trolltech.com/4.3/qwidget.html#resizeEvent

From the documentation:
"When resizeEvent() is called, the widget already has its new geometry."

Overriding QWidget::resizeEvent() to prevent resizing won't work,
because, per above, the widget has already been resized when the
resize event comes in. So resizing a top-level widget would likely
result in the appearance of the widget "jumping" between
mouse-selected size and the forced size - not pretty. At best, the
widget will look wrong (if the widget is in a layout, the layout will
expect the widget to respect setGeometry calls), at worst it will
crash (stack overflow observed on Windows with the attached simple
test).

-- 
 [ signature omitted ] 
#include <QApplication>
#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#include <QResizeEvent>

class MyWidget: public QLabel
{
public:
	MyWidget(QWidget* parent = NULL);
	~MyWidget();

protected:
	void resizeEvent(QResizeEvent*);
};


MyWidget::MyWidget(QWidget* parent):
	QLabel(parent)
{
}

MyWidget::~MyWidget()
{
}

void MyWidget::resizeEvent(QResizeEvent* e)
{
	if (e->size().height() != 100)
		resize(e->size().width(), 100);
}

int main(int argc, char* argv[])
{
	QApplication app(argc, argv);
	
	QPushButton* b1 = new QPushButton();
	b1->setText("Button 1");
	QPushButton* b2 = new QPushButton();
	b2->setText("Button 2");

	MyWidget* w1 = new MyWidget();
	w1->setText("This wont't resize");
	w1->resize(200,100);

	QVBoxLayout* hb = new QVBoxLayout();
	hb->addWidget(b1);
	hb->addWidget(w1);
	hb->addWidget(b2);

	QWidget* w = new QWidget();
	w->setLayout(hb);
	w->show();

	MyWidget* w2 = new MyWidget();
	w2->setText("This wont't resize");
	w2->resize(200,100);
	w2->show();

	return app.exec();
}

Message 5 in thread

On Mon, Dec 17, 2007, Andrew Medico wrote :
> On Dec 16, 2007 3:09 PM, Benjamin Sergeant <bsergean@xxxxxxxxx> wrote:
> > Just trying to guess:
> >
> > What you could try: overwrite resizeEvent and tell it to don't resize
> > horizontally.
> > http://doc.trolltech.com/4.3/qwidget.html#resizeEvent
> 
> >From the documentation:
> "When resizeEvent() is called, the widget already has its new geometry."
> 
> Overriding QWidget::resizeEvent() to prevent resizing won't work,
> because, per above, the widget has already been resized when the
Yeah, I couln't find yet a solution, I am a bit stucked on that part...

Best Regards,

-- 
 [ signature omitted ]