Results 1 to 5 of 5

Thread: QWidget Attachments

  1. #1
    Join Date
    Sep 2009
    Location
    Las Vegas, Nevada - USA
    Posts
    12
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default QWidget Attachments

    I am currently working in Windows environment but want to port to MacOS and Unix (Linux). I am from the old school and actually worked on XWindows on the RS-6000 and HP-Unix (1992-1995) using X11.

    I was wondering if Qt has the equivalent to attachtop, attachleft, attachright…

    This was wonderful when doing resizing, because your widgets would keep in alignment when resizing the form.

    I been reading and can’t find anything about attachments, but seem like it should be implemented.

    Thank you in advance.

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWidget Attachments

    Qt has the concept of layouts, which is usable on any supported platform. As far as I can see, the layout system is at least just as powerful as the attach* functions.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. #3
    Join Date
    Sep 2009
    Location
    Las Vegas, Nevada - USA
    Posts
    12
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QWidget Attachments

    I am working in Qt Creator, and I notice the 4 types of layouts. But did they every mess up my layout. Maybe I need a better place on describing the layout then the help files.

  4. #4
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWidget Attachments

    In my experience designer is good for simple layouting. If you need complex stuff (e.g. excessive column or row spanning) you really should code it yourself.

    Qt Code:
    1. QGridLayout *layout = new QGridLayout;
    2.  
    3. QPushButton *b = new QPushButton("some text", this);
    4.  
    5. layout->addWidget(b, 0, 0, 1, 1);
    6.  
    7. this->setLayout(layout);
    To copy to clipboard, switch view to plain text mode 
    Last edited by franz; 27th September 2009 at 20:42. Reason: updated contents
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

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

    Default Re: QWidget Attachments

    Quote Originally Posted by BingoMaster View Post
    But did they every mess up my layout.
    You probably just used them incorrectly. The most important thing to remember is that you apply layouts to parent of the widgets you want to be controlled. So at least you have to apply the layout to the form itself by clicking inside it (so that no other widgets are selected) and clicking one of the layout icons in the toolbar. Of course you can nest layouts by applying a layout to a subset of widgets first and then on the top-level form.
    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.


Similar Threads

  1. Promoting the parent QWidget of a QWidget form
    By extrakun in forum Qt Tools
    Replies: 6
    Last Post: 16th April 2010, 14:19
  2. Adding a scrollbar to a QWidget
    By qtUser500 in forum Newbie
    Replies: 13
    Last Post: 2nd September 2009, 19:48
  3. Replies: 0
    Last Post: 11th November 2008, 15:36
  4. Dynamic updates of a QWidget in a QScrollArea
    By plamkata in forum Qt Programming
    Replies: 2
    Last Post: 20th July 2008, 23:45
  5. Error in put one QWidget in another QWidget
    By xjtu in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2008, 16:05

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.