Results 1 to 12 of 12

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

Hybrid View

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

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

    Rexi: Thanks for the QWidget information .

    wysota: Appreciate your detailed reply.

    • I tried out what you suggested in Ur .ui, and was able to create the QSplitter (Horizontal) with the QListBox and the QFrame.
    • I also put the layout of mainWindowBase to Horizontal, so that the QListBox and the QFrame resize when the window is resized


    Questions (The last ones I promise )
    I am trying to add the documentView at runtime. I get it to appear, but not in the appropriate way. This is what I did:

    - Create a Layout, add the documentView to the layout, setLayout to the QFrame. But when I do this I see the documentView on the extreme left partially covering the side toolbar. The code is:

    Qt Code:
    1. QBoxLayout* docLayout = new QHBoxLayout( docFrame );
    2. docLayout->add(documentView); // 'documentView' is the object I want in the layout and eventually in the QFrame
    To copy to clipboard, switch view to plain text mode 

    I actually don't need a horozontal/ vertical layout as the 'documentView' object is the only one I want in the QFrame. But I get an error when I try to use QLayout()

    I am near and yet so far ...Please suggest how I can dynamically add the document view without the layout being skewed... thanks in advance wysota !
    Last edited by qtUser500; 24th February 2009 at 18:13.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

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

    Use addWidget() and not add().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

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

    Thanks wysota , but addWidget too doesn't work.
    Please see the enclosed screenshot when I used 'addWidget'.

    The document View is displayed at the extreme top left corner.

    Thanks!
    Attached Images Attached Images

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

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

    It seems it is not added to the layout. Can you provide a larger snippet of code I might have a look at? Especially what you do with docFrame and what documentView is.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Feb 2009
    Posts
    45
    Thanks
    3
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

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

    Due to code confidentiality I unfortunately can't reveal the exact details but I have attached the skeleton .ui file, removing most of the toolbar actions. The rest of the layout in the UI is as is. Note that I have used Qt 3.3.5

    docFrame: After adding it in the UI, I only access it when setting the layout for the frame ie.
    Qt Code:
    1. QHBoxLayout* docLayout = new QHBoxLayout(docFrame);
    To copy to clipboard, switch view to plain text mode 

    documentView:
    Qt Code:
    1. documentView= new ViewClass(QWidget*, QString); // Changed due to propriety reasons
    To copy to clipboard, switch view to plain text mode 

    Thanks for UR time wyosa, it is really appreciated!
    Attached Files Attached Files

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

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

    Well... unfortunately this doesn't say much more than what you already told us. Believe me, I've seen thousands of Qt object construction snippets. I'm sure yours is as standard as any else and won't reveal any sensitive information. I'm not asking about any logic, just the user interface creation code. What is the base class of "documentView"? Also please use addWidget() instead of add() even if the latter compiles. Also why don't you get rid of the frame and use the custom widget approach I suggested earlier? It would make your problem disappear right away as Qt would build the proper layout code for you.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Feb 2009
    Posts
    45
    Thanks
    3
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

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

    Thanks wysota, I was able to fix the issue. It was in the constructor of the documentView, I had to set the docFrame as the parent.

    Thank you for all your time!

Similar Threads

  1. Replies: 1
    Last Post: 8th February 2009, 11:37
  2. QHBoxlayout Size problem
    By Spitz in forum Qt Programming
    Replies: 2
    Last Post: 4th December 2008, 21:09
  3. Drawing on QWidget - strech & resize
    By kemp in forum Qt Programming
    Replies: 5
    Last Post: 22nd January 2007, 14:39
  4. QHBoxLayout Problem
    By Seema Rao in forum Qt Programming
    Replies: 5
    Last Post: 29th April 2006, 15: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.