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

Qt-interest Archive, May 2007
Newbe QLayout::setSizeConstraint query


Message 1 in thread

Hi all,

Newbe here, trying to solve QT app bug. The header file includes ....

#include <QLabel>
class QLabel;
...

/**
  * Task editor window.
  */
class KTTask : public KDialog
{




The cpp file includes ...

KTTask::KTTask(CTTask* _cttask, const QString & _caption)
       :KDialog( 0 )
{
  QWidget *main = new QWidget(this);
  setMainWidget(main);
...



After several nested layout classes are defined, the main widget needs
to have its size fixed so it cant be resized ... looking around QT4 I
get ...

  QLayout::setSizeConstraint(QLayout::SetFixedSize);

error: cannot call member function 'void
QLayout::setSizeConstraint(QLayout::SizeConstraint)' without object






OK can anyone tell me where I am going wrong ?

Cheers

Dave












-- 
 [ signature omitted ] 

Message 2 in thread

QLayout::setSizeConstraint() is not a static function and cannot be
called as such.  You need to work on an actual instance of a QLayout
object.  If you want to modify the main widget's layout, you might do
something like this:

main->layout()->setSizeConstraint(QLayout::SetFixedSize);

All QWidgets have the layout() method which returns a pointer to their
QLayout manager.

Hope that helps.

Stuart

> Hi all,
>
> Newbe here, trying to solve QT app bug. The header file includes ....
>
> #include <QLabel>
> class QLabel;
> ...
>
> /**
>  * Task editor window.
>  */
> class KTTask : public KDialog
> {
>
>
>
>
> The cpp file includes ...
>
> KTTask::KTTask(CTTask* _cttask, const QString & _caption)
>       :KDialog( 0 )
> {
>  QWidget *main = new QWidget(this);
>  setMainWidget(main);
> ...
>
>
>
> After several nested layout classes are defined, the main widget needs
> to have its size fixed so it cant be resized ... looking around QT4 I
> get ...
>
>  QLayout::setSizeConstraint(QLayout::SetFixedSize);
>
> error: cannot call member function 'void
> QLayout::setSizeConstraint(QLayout::SizeConstraint)' without object
>
>
>
>
>
>
> OK can anyone tell me where I am going wrong ?
>
> Cheers
>
> Dave
>
>
>
>
>
>
>
>
>
>
>
>


Attachment:

Attachment: signature.asc
Description: OpenPGP digital signature