Results 1 to 13 of 13

Thread: QMainWindow - issue

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default QMainWindow - issue

    Hello forum

    I have subclass the QMainWindow and it contains another widget as a central widget. The size of the central widget depends on the size of the widget. I am trying to set the widget size inside the constructor of the subclassed QMainWindow.


    Qt Code:
    1. //GETTING ERROR ON THE FOLLOWING TWO LINES
    2. int width = sizeHint().width();
    3. int height = sizeHint().height();
    4.  
    5. //set width and height of the glwindow - WHICH IS THE WIDGET OF ANOTHER TYPE
    6. m_glWindow->width->setValue(width);
    7. m_glWindow->height->setValue(height);
    8.  
    9. setCentralWidget(m_glWindow);
    To copy to clipboard, switch view to plain text mode 


    The error that i got is :


    Qt Code:
    1. H3DMainWindow.cpp:24: warning: when initialized here
    2. H3DMainWindow.cpp:52: error: request for member ‘width’ is ambiguous
    3. /usr/local/Trolltech/Qt-4.8.0/include/QtGui/qpaintdevice.h:91: error: candidates are: int QPaintDevice::width() const
    4. /usr/local/Trolltech/Qt-4.8.0/include/QtGui/qwidget.h:1026: error: int QWidget::width() const
    5. /usr/local/include/H3D/H3DWindowNode.h:267: error: std::auto_ptr<H3D::SFInt32> H3D::H3DWindowNode::width
    6. H3DMainWindow.cpp:53: error: request for member ‘height’ is ambiguous
    7. /usr/local/Trolltech/Qt-4.8.0/include/QtGui/qpaintdevice.h:92: error: candidates are: int QPaintDevice::height() const
    8. /usr/local/Trolltech/Qt-4.8.0/include/QtGui/qwidget.h:1029: error: int QWidget::height() const
    9. /usr/local/include/H3D/H3DWindowNode.h:273: error: std::auto_ptr<H3D::SFInt32> H3D::H3DWindowNode::height
    10. H3DMainWindow.cpp: At global scope:
    11. H3DMainWindow.cpp:369: warning: unused parameter ‘fileName’
    12. make: *** [H3DMainWindow.o] Error 1
    13. sajjad@sajjad:~/Documents/H3DViewer$
    To copy to clipboard, switch view to plain text mode 



    Any hint to get around ?



    Regards
    Sajjad

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QMainWindow - issue

    I think you will find that the error messages are related to the later two lines:
    Qt Code:
    1. //set width and height of the glwindow - WHICH IS THE WIDGET OF ANOTHER TYPE
    2. m_glWindow->width->setValue(width);
    3. m_glWindow->height->setValue(height);
    To copy to clipboard, switch view to plain text mode 
    and that the m_glWindow widget (a QGLWidget perhaps?) has no member variable called width/height. When the compiler looks for "width" it finds two options and doesn't know which you mean. (How you arrived at the code you wrote is a mystery to me.) I think you probably wanted:
    Qt Code:
    1. m_glWindow->resize(width, height);
    To copy to clipboard, switch view to plain text mode 

    The exercise is probably pointless because making the m_glWindow the centralWidget() will make it fill the client area of the main window anyway. It may also adjust the size hint.

Similar Threads

  1. Replies: 6
    Last Post: 13th November 2011, 09:31
  2. Replies: 3
    Last Post: 13th November 2011, 08:12
  3. Replies: 2
    Last Post: 29th June 2011, 15:45
  4. Replies: 1
    Last Post: 28th October 2008, 16:29
  5. QMainWindow Maximization Issue
    By vishal.chauhan in forum Qt Programming
    Replies: 6
    Last Post: 15th March 2007, 13:30

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.