Skip to content
QtWS25 Last Chance
  • are there only five kinds of layouts in Qt?

    Solved General and Desktop qt 6 qlayout layout
    4
    0 Votes
    4 Posts
    267 Views
    Pl45m4P
    @markleo said in are there only five kinds of layouts in Qt?: Or are there only five kinds of layouts in Qt? Yes and no. In most cases these are the base layouts used. However there are also custom layouts with "special" behavior, like FlowLayout from the Flow Layout Example. That being said, you can combine the basic layout or build your own layout, if you really need something different (what you cannot reproduce using the five above).
  • 0 Votes
    7 Posts
    427 Views
    Pl45m4P
    @herocon Ok next attempt: ui->label->setPixmap(p.scaled(ui->label->size())); Each iteration scales the pixmap to current label size and then sets the pixmap to the label. By doing this, the size of the label increases with the pixmap (because of border/frame... IIRC 1px per side by default, so 2px in total). Then you take the new label size again in the next iteration and apply this new (by 2px) increased size to the pixmap... the label gets the pixmap, grows by about 2px in height and there you have your loop where your label and consequently the whole widget grows ;-) So still no bug :) And it's exactly the behavior you would expect from the debug output. (The height increases by 2 each timer interval). When using another layout setup, the layout/other widgets might "buffer" that, so the main app window does not grow. But even there, the label itself should definitely grow when you periodically set content which has the exact same size as the outter boundings of the label. Why though?! Try (not tested): int w = ui->label->width(); int h = ui->label->height(); ui->label->setPixmap(p.scaled(w - 2, h - 2)); // or this and set the pixmap only once ui->label->setScaledContents(true); Because a label with w=500, h=500 for example, can't display a pixmap with w=500, h=500. If you set a pixmap with the same size as the label itself, it will start to grow.
  • Custom Widget not showing in layout

    Solved General and Desktop qwidget qlayout custom widget
    9
    0 Votes
    9 Posts
    2k Views
    S
    @Pl45m4 said in Custom Widget not showing in layout: always returning QSize(width(), height()); doesn't feel like the best solution ;-) I guess that QPushButton uses the actual text displayed (plus some padding) to calculate the size hint. QFontMetrics might help here.
  • 0 Votes
    5 Posts
    828 Views
    NarutoblazeN
    @mpergand Did not worked : setSectionResizeMode(QHeaderView::Fixed); setDefaultSectionSize(10);
  • 0 Votes
    1 Posts
    695 Views
    No one has replied
  • Maintain aspect ratio of application

    Unsolved General and Desktop qlayout
    2
    0 Votes
    2 Posts
    443 Views
    nageshN
    @arjun98 I think this can be achieved In the layout by setting the strech factor
  • 0 Votes
    3 Posts
    1k Views
    D
    Thank you, I actually commented out the delete because I wasn't sure of the removeWidget behaviour, now it works flawlessly
  • 0 Votes
    5 Posts
    948 Views
    D
    @SGaist I ended up hocking up to resize event of parent widget to find out when size changed & resize my other widget acordingly. I ended up using "invisible" QLabel that retains size as my "spacer". I had to change its spacing role on the go depending of one or more widget are visible or not as I needed to retain correct order. So far works great. TIA
  • 0 Votes
    4 Posts
    2k Views
    mrjjM
    @Rohith Hi Im not sure what goes wrong. I guess you are still not using the RIGHT click layout menu ? Do not drag layouts from left box. Please see this video. https://www.dropbox.com/s/t3icclcqb446jkm/scroll.mp4?dl=0
  • 0 Votes
    5 Posts
    5k Views
    SGaistS
    No, it doesn't. The QLayoutItem is not the parent of the widget, it is not a QObject. That's not its job.
  • Values of dynamically created QLineEdit

    Unsolved General and Desktop qlayout qlineedit
    4
    0 Votes
    4 Posts
    2k Views
    K
    @Tirolel If you want t do it that way you shouldn't you cast the widget to find out what type it is before you actually use it? if(qobject_cast<QLineEdit*>(pLine->widget()) != 0) ... Test for which type it is then use the correct type cast to use the actual member functions...
  • Problem with using layouts with custom widgets

    Unsolved General and Desktop qlayout custom widgets
    2
    0 Votes
    2 Posts
    885 Views
    kshegunovK
    @bigThrum Hi, wid->setLayout(layout); wid2->setLayout(layout); This will not work. You need to have a separate layout object for each of your widgets, and a separate set of QPushButton objects for each of the layouts. Kind regards.
  • Cannot add widgets to layout

    Unsolved General and Desktop qlayout qwidget qmainwindow vlc-qt
    18
    0 Votes
    18 Posts
    10k Views
    kshegunovK
    @AyushExel204 It is indeed strange. I haven't worked with that library, but I see no good reason that is should work with VlcMediaPlayer but not with VlcMediaListPlayer. In this example (graciously provided by @mrjj over chat), they don't seem to use VlcMediaListPlayer and as you said that should work. Perhaps you can use it to build upon. Also you might want to search through the library's bugtracker to see if there is something known about this issue.
  • Can VLC-Qt widgets be used as Qt Widgets

    Unsolved General and Desktop qlayout qwidget vlc-qt
    3
    0 Votes
    3 Posts
    4k Views
    SGaistS
    Hi, Why can't it be used a QWidgets ? From a quick look at the documentation WidgetVideo is a QWidget so you can put it in a layout. You have to create the WidgetVideo yourself and set it on your media player. WARNING: not tested, it comes from the documentation of VlcQt and their example.
  • Align buttons on the right side of QHBoxLayout.

    Unsolved General and Desktop qhboxlayout qlayout
    5
    0 Votes
    5 Posts
    14k Views
    T
    I do insertWidget(1, rHomeButton_, 0, Qt::AlignRight); and so on for all buttons but it doesn't affect
  • Elements of the same size in two GroupBoxes

    Unsolved General and Desktop qgroupbox qlayout qtdesigner
    7
    0 Votes
    7 Posts
    2k Views
    mrjjM
    @Wieland Ah. thank you. Ok, you are right - spacer wont do it. He could set Alignment to right. (for edit) Then they stay same with all the time. Not sure its 100% the wanted effect? https://www.dropbox.com/s/px3t6ir6d767nn7/keepright.zip?dl=0
  • 0 Votes
    2 Posts
    1k Views
    Chris KawaC
    I'm not that fluent in python, but layout_final.addWidget(self.widgetGL) layout_final.addWidget(self.widget) Horizontal layouts add stuff left to right, so, if anywhere, the GL widget would be on the left, not on the right. I don't think a GL widget has any minimum size. It might be that the other widgets have "greedy" horizontal size policies (I think a label does by default). Try setting a minimum width or an expanding horizontal size policy on the GL widget.
  • QLayout is wasting space

    Unsolved General and Desktop qlayout qwidget
    7
    0 Votes
    7 Posts
    2k Views
    R
    I added ui->verticalLayout->parentWidget()->setSizePolicy(QSizePolicy::Policy::Preferred, QSizePolicy::Policy::Maximum); which organized the containing widgets perfectly. But that opened another problem, No I can not resize (move border between dockwidgets) between the Dockwidgets..
  • 0 Votes
    3 Posts
    3k Views
    J
    @onek24 You're absolutely right. I didn't yet grasp that the QLayoutItem in fact behaves as a kind of proxy for the actual widget (or child-layout). Thanks for the clarification.