Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Qt4 - Layout Issues
Qt 6.11 is out! See what's new in the release blog

[SOLVED] Qt4 - Layout Issues

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello,
    I have some difficulties to understand layouts and I don't know what to do to solve my problems. Here is what I have :

    !http://img842.imageshack.us/img842/3885/a94t.png(test)!

    First, I'd like the "Actions" QGroupBox to stick on top of the window and not to expand like this.

    Then, I have to do like follow if I don't want the window to be completely crushed when launched : (this is a QWidget and _table is a QTableWidget)

    @ _table->setColumnWidth(0,175);
    _table->setColumnWidth(1, 75);
    _table->setColumnWidth(2, 50);
    _table->setColumnWidth(3, 150);
    _table->setColumnWidth(4, 75);
    _table->setColumnWidth(5, 300);
    this->resize(1200, 400);@

    How can I say to my window to consider the width of my table ?
    So that I don't have to set it manually.

    Also, how can I set automatically the width of each columns of my table to the max width of their content (text for example) ? Or the size of their title by default (like in this case).

    Thanks in advance !

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi, you want QBoxLayout::addStretch(), QTableView::resizeColumnsToContents(), and QWidget::setMinimumWidth()

      Two tips:

      Read the documentation -- Qt's docs are widely considered to be very comprehensive. Don't forget to check a class' inherited functions too.

      Use Qt Designer for laying out custom widgets -- It will likely save you lots of time in the long run

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved