Results 1 to 6 of 6

Thread: Qt Complex layout for a note-taking app

  1. #1

    Default Qt Complex layout for a note-taking app

    I have a qt app that uses a very bad technique for resizing. The current approach is to put all the main elements inside a form, and when resizing is happening, change the size and place of the objects through custom code. It's an ugly, hard to maintain, and not good for future features approach.

    What should be done is to use the tools qt have for handling layouts. I've tried and failed. I would like your help with it. e You can take a look at the app here: https://github.com/nuttyartist/notes

    The source is there. Also, here is a screenshot from the qtcreator form:
    http://i.imgur.com/glGn3ES.png?1

    I'm okay with creating the layout through code.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt Complex layout for a note-taking app

    You need to start creating the interface top down.

    You obviously want the top level to be layouted horizontally, having a left side and a right side divded by a line.
    Btw, you might want to consider using a splitter instead of the line.

    On the left side widget you add the text edit, the two buttons and the label.
    Then you CTRL+Left Click the buttons and the label and click the "horizontal layout" button.
    Then select the left side widget and click the vertical layout button.

    Repeat similar steps for the left side widget.

    Cheers,
    _

  3. #3

    Default Re: Qt Complex layout for a note-taking app

    Quote Originally Posted by anda_skoa View Post
    You need to start creating the interface top down.

    You obviously want the top level to be layouted horizontally, having a left side and a right side divded by a line.
    Btw, you might want to consider using a splitter instead of the line.

    On the left side widget you add the text edit, the two buttons and the label.
    Then you CTRL+Left Click the buttons and the label and click the "horizontal layout" button.
    Then select the left side widget and click the vertical layout button.

    Repeat similar steps for the left side widget.

    Cheers,
    _

    I am struggling to implement that in a way that my app will work like it's working now.
    Here is what I got: http://i.imgur.com/6pAFTB0.png
    But there are few problems:
    1. I want widgets to be at a fixed size I decide. Fixed policy isn't doing it.
    2. The space between widgets, between widget and the main window and between layouts to the line should not be there.
    3. The closse-minimze-maximize buttons not sit in the way they should. they shouldn't be on the same 'y' axis as the plus and trash buttons, but above them.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt Complex layout for a note-taking app

    Quote Originally Posted by robi9011235 View Post
    1. I want widgets to be at a fixed size I decide. Fixed policy isn't doing it.
    You can set a fixed size

    Quote Originally Posted by robi9011235 View Post
    2. The space between widgets, between widget and the main window and between layouts to the line should not be there.
    Layouts have margins by default, you can set them to 0

    Quote Originally Posted by robi9011235 View Post
    3. The closse-minimze-maximize buttons not sit in the way they should. they shouldn't be on the same 'y' axis as the plus and trash buttons, but above them.
    You could add a vertical spacer to the right hand side layout to move the buttons further down.

    Or you don't use a left/right approach but a grid layout.

    Cheers,
    _

  5. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,120
    Thanks
    235
    Thanked 656 Times in 646 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Qt Complex layout for a note-taking app

    You can set a fixed size
    But be aware that fixed sizes can be problematic. I recently got a 4K monitor. I found that the default font size was too small to be easily readable, so I changed it to 125% magnification. As a consequence, everywhere that I had specified fixed sizes for text in my layouts was now too small for the text. The pixel sizes of the layouts hadn't changed, but effectively the font size did.

  6. #6

    Default Re: Qt Complex layout for a note-taking app

    Quote Originally Posted by anda_skoa View Post
    You can set a fixed size


    Layouts have margins by default, you can set them to 0


    You could add a vertical spacer to the right hand side layout to move the buttons further down.

    Or you don't use a left/right approach but a grid layout.

    Cheers,
    _
    Quote Originally Posted by d_stranz View Post
    But be aware that fixed sizes can be problematic. I recently got a 4K monitor. I found that the default font size was too small to be easily readable, so I changed it to 125% magnification. As a consequence, everywhere that I had specified fixed sizes for text in my layouts was now too small for the text. The pixel sizes of the layouts hadn't changed, but effectively the font size did.
    I should have prbobably stated that earlier, the prbolem is solved, pushed changes to the repo.
    Thanks.

Similar Threads

  1. Widgets taking too much space hidden on a Layout
    By mrlinx in forum Qt Programming
    Replies: 5
    Last Post: 2nd September 2011, 00:19
  2. No xshape support note
    By impeteperry in forum Installation and Deployment
    Replies: 16
    Last Post: 18th August 2006, 20:10
  3. Note book widget
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 30th May 2006, 19:02
  4. QT4 layout of complex dialog is very slow
    By cboles in forum Qt Programming
    Replies: 15
    Last Post: 28th April 2006, 19:57

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.