Results 1 to 2 of 2

Thread: moving widget to Right using QSpacerItem

  1. #1
    Join Date
    Aug 2013
    Posts
    41
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default moving widget to Right using QSpacerItem

    Hello,

    Please have a look at the screen shot attached. I would like to move the graph to right (next to the widget behind the graph). There two widgets are independent and have seperate layouts.
    I have used QSpacerItem to the grid layout and I got space to the right of the graph. I want spacing to be added from its left so that it is placed next to the widget behind it.

    I have written the following lines to produce the screen shot attached:

    Qt Code:
    1. QVBoxLayout *MainLayout = new QVBoxLayout(this);
    2. QGridLayout *GridLayoutM = new QGridLayout();
    3.  
    4. mPlotPost = new PlotPost(this); //widget containing the graph
    5. GridLayoutM->addWidget(mPlotPost);
    6. GridLayoutM->addItem( new QSpacerItem(1,1,QSizePolicy::Expanding, QSizePolicy::Expanding), 2, 6);
    7. MainLayout->addLayout(GridLayoutM);
    To copy to clipboard, switch view to plain text mode 

    I have tried changing the coordinates in QSpacerItem, but the spacing does not change as desired.
    I have also tried addStrech() method by using QHBoxLayout, but even that adds space from right side!
    Attachment 9658
    Please help.
    Last edited by uz_qt; 1st October 2013 at 16:17.

  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: moving widget to Right using QSpacerItem

    Fix your attachment. Cannot see what you mean.

Similar Threads

  1. How do I add a QSpacerItem to a toolbar?
    By di_zou in forum Newbie
    Replies: 5
    Last Post: 23rd June 2021, 02:12
  2. Moving widget to second screen not working
    By binaural in forum Qt Programming
    Replies: 2
    Last Post: 6th September 2012, 22:09
  3. custom widget that contains moving parts
    By cgyan1 in forum Qt Programming
    Replies: 2
    Last Post: 14th February 2012, 15:47
  4. mouseMoveEvent: KDE moving widget
    By NullPointer in forum Newbie
    Replies: 1
    Last Post: 17th August 2011, 14:57
  5. [Qt4] - Moving Widget...
    By IPFreely in forum Qt Programming
    Replies: 1
    Last Post: 13th June 2006, 09:32

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.