Results 1 to 12 of 12

Thread: Help needed in adding QWidget and other objects to a QHBoxLayout

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2009
    Posts
    45
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows
    Thanks
    3

    Default Help needed in adding QWidget and other objects to a QHBoxLayout

    I am using Qt 3.3.5 and trying to emulate how the Acrobat PDF viewer works i.e. to view thumbnails of a document loaded.
    The enclosed attachment details the layout I need.

    Scenario

    I have a 'MainWindowBase' in which I :
    1. created 2 toolbars, one on top, and a left toolbar.
    2. The main window loads a 'document' which I can navigate just like Acrobat. All this works fine.


    I want to add:

    A column (QListBox) to the left of the document, this will contain the thumbnails of the document (a la Acrobat viewer).

    Code
    I can't see QWidget lsited under 'Containers'in my QtDesigner, hence I am creating one at runtime. My code is as follows:
    Qt Code:
    1. QWidget *mainWidget = new QWidget;
    2. QHBoxLayout* mainHLayout = new QHBoxLayout( mainWidget, 25, 0);
    3.  
    4. // ListBox for thumbnail sidebar
    5. QListBox *thbNailListBox = new QListBox();
    6. //thbNailListBox->setEnabled(true);
    7. //thbNailListBox->setGeometry(10,10,50,100);
    8. mainHLayout->add(thbNailListBox);
    9. mainHLayout->addWidget(documentView); // documentView is the 'Document' object
    10.  
    11. setCentralWidget ( mainWidget );
    To copy to clipboard, switch view to plain text mode 


    Problem
    1. I don't see the QListBox and the 'documentView' is not visible at the extreme top left corner
    2. While using QHBoxLayout, to view the toolbars I need to put spacing = 25, if not the toolbars are covered by the mainWidget
    3. But using spacing = 25, makes the window look ackward as there is an extra spacing of 25 on the right as well as bottom of the main window
    4. How can I add a QWidget to the QtDesigner?


    Could anyone suggest how best I can go about with this.
    Any pointers will be appreciated.

    Thanks,
    Attached Images Attached Images
    Last edited by qtUser500; 23rd February 2009 at 21:37.

Similar Threads

  1. Replies: 1
    Last Post: 8th February 2009, 12:37
  2. QHBoxlayout Size problem
    By Spitz in forum Qt Programming
    Replies: 2
    Last Post: 4th December 2008, 22:09
  3. Drawing on QWidget - strech & resize
    By kemp in forum Qt Programming
    Replies: 5
    Last Post: 22nd January 2007, 15:39
  4. QHBoxLayout Problem
    By Seema Rao in forum Qt Programming
    Replies: 5
    Last Post: 29th April 2006, 16:51

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.