mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-09-26 17:30:32 -04:00
idian: Fix RowList insert position and count
The rowLayout index is 0 which means the header was being inserted at index -1. Qt interprets negative indexes as the end of the list, which caused it to be inserted after the actual rows, rather than before. This also makes the count of rows public.
This commit is contained in:
@@ -35,6 +35,8 @@ public:
|
||||
void addRow(QWidget *row);
|
||||
void clear();
|
||||
|
||||
int count() const;
|
||||
|
||||
private:
|
||||
QWidget *first = nullptr;
|
||||
QWidget *last = nullptr;
|
||||
|
||||
@@ -39,7 +39,7 @@ RowList::RowList(QWidget *parent) : QFrame(parent)
|
||||
|
||||
void idian::RowList::addHeader(QWidget *widget)
|
||||
{
|
||||
layout->insertWidget(layout->indexOf(rowLayout) - 1, widget);
|
||||
layout->insertWidget(layout->indexOf(rowLayout), widget);
|
||||
}
|
||||
|
||||
// Note: This function takes ownership of the added widget
|
||||
@@ -48,7 +48,7 @@ void idian::RowList::addHeader(QWidget *widget)
|
||||
void RowList::addRow(QWidget *widget)
|
||||
{
|
||||
// Add custom spacer when more than one row exists
|
||||
if (rowLayout->count() > 0) {
|
||||
if (count() > 0) {
|
||||
rowLayout->addWidget(new RowListSpacer(this));
|
||||
}
|
||||
|
||||
@@ -88,3 +88,8 @@ void RowList::clear()
|
||||
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
int idian::RowList::count() const
|
||||
{
|
||||
return rowLayout->count();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user