minor adjustments to Qt layout

This commit is contained in:
Jan Käberich 2021-04-06 18:29:41 +02:00
parent 8865de81b7
commit ba62925b67
3 changed files with 114 additions and 125 deletions

View File

@ -223,6 +223,8 @@ SOURCES += \
unit.cpp unit.cpp
LIBS += -lusb-1.0 LIBS += -lusb-1.0
unix:LIBS += -L/usr/lib/
win32:LIBS += -L"$$_PRO_FILE_PWD_" # Github actions placed libusb here
QT += widgets QT += widgets

View File

@ -13,6 +13,7 @@ SignalgeneratorWidget::SignalgeneratorWidget(QWidget *parent) :
ui->span->setUnit("Hz"); ui->span->setUnit("Hz");
ui->span->setPrefixes(" kMG"); ui->span->setPrefixes(" kMG");
ui->span->setPrecision(6); // show enough digits ui->span->setPrecision(6); // show enough digits
ui->span->setValue(0);
ui->current->setUnit("Hz"); ui->current->setUnit("Hz");
ui->current->setPrefixes(" kMG"); ui->current->setPrefixes(" kMG");
@ -21,10 +22,10 @@ SignalgeneratorWidget::SignalgeneratorWidget(QWidget *parent) :
ui->dwell->setUnit("s"); ui->dwell->setUnit("s");
ui->dwell->setPrefixes(" m"); ui->dwell->setPrefixes(" m");
ui->dwell->setPrecision(6); // show enough digits ui->dwell->setPrecision(6); // show enough digits
ui->dwell->setValueQuiet(1); ui->dwell->setValue(1);
m_timerId = startTimer(1000); m_timerId = startTimer(1000);
ui->steps->setValueQuiet(100); ui->steps->setValue(100);
ui->steps->setPrefixes(" k"); ui->steps->setPrefixes(" k");
ui->steps->setPrecision(0); ui->steps->setPrecision(0);
@ -57,8 +58,9 @@ SignalgeneratorWidget::SignalgeneratorWidget(QWidget *parent) :
ui->frequency->setValueQuiet(ui->span->value()/2); ui->frequency->setValueQuiet(ui->span->value()/2);
} }
newF = ui->frequency->value() + ui->span->value()/2; newF = ui->frequency->value() + ui->span->value()/2;
if (newF > Device::Info().limits_maxFreq) if (newF > Device::Info().limits_maxFreq) {
ui->frequency->setValueQuiet(Device::Info().limits_maxFreq - ui->span->value()/2); ui->frequency->setValueQuiet(Device::Info().limits_maxFreq - ui->span->value()/2);
}
newval = ui->frequency->value() - ui->span->value()/2; newval = ui->frequency->value() - ui->span->value()/2;
@ -76,8 +78,8 @@ SignalgeneratorWidget::SignalgeneratorWidget(QWidget *parent) :
}); });
connect(ui->dwell, &SIUnitEdit::valueChanged, [=](double newval) { connect(ui->dwell, &SIUnitEdit::valueChanged, [=](double newval) {
if(newval < 0 ) { if(newval < 0.01 ) {
newval = 0; newval = 0.01;
} else if (newval > 60) { } else if (newval > 60) {
newval = 60; newval = 60;
} }
@ -102,8 +104,9 @@ SignalgeneratorWidget::SignalgeneratorWidget(QWidget *parent) :
} }
emit SettingsChanged(); emit SettingsChanged();
}); });
connect(ui->EnabledSweep, &QCheckBox::clicked, [=](){ connect(ui->EnabledSweep, &QCheckBox::toggled, [=](bool enabled){
if(ui->EnabledSweep->isChecked()) { ui->current->setEnabled(enabled);
if(enabled) {
double newF = ui->frequency->value() - ui->span->value()/2; double newF = ui->frequency->value() - ui->span->value()/2;
if (newF < 0) { if (newF < 0) {
ui->frequency->setValueQuiet(ui->frequency->value() - newF); ui->frequency->setValueQuiet(ui->frequency->value() - newF);

View File

@ -38,6 +38,19 @@
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="font"> <property name="font">
@ -59,7 +72,7 @@
<item> <item>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="title"> <property name="title">
<string>Frequency:</string> <string>Frequency</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
@ -148,125 +161,96 @@
<property name="title"> <property name="title">
<string>Sweep</string> <string>Sweep</string>
</property> </property>
<widget class="SIUnitEdit" name="span"> <layout class="QVBoxLayout" name="verticalLayout_5">
<property name="geometry"> <item>
<rect> <widget class="QCheckBox" name="EnabledSweep">
<x>60</x> <property name="text">
<y>40</y> <string>Enabled</string>
<width>133</width> </property>
<height>20</height> </widget>
</rect> </item>
</property> <item>
<property name="text"> <layout class="QFormLayout" name="formLayout">
<string>0MHz</string> <item row="0" column="0">
</property> <widget class="QLabel" name="label_2">
</widget> <property name="text">
<widget class="QLabel" name="label_2"> <string>Span:</string>
<property name="geometry"> </property>
<rect> </widget>
<x>10</x> </item>
<y>40</y> <item row="0" column="1">
<width>47</width> <widget class="SIUnitEdit" name="span">
<height>13</height> <property name="text">
</rect> <string>0MHz</string>
</property> </property>
<property name="text"> </widget>
<string>Span:</string> </item>
</property> <item row="1" column="0">
</widget> <widget class="QLabel" name="label_3">
<widget class="SIUnitEdit" name="steps"> <property name="text">
<property name="geometry"> <string>Steps:</string>
<rect> </property>
<x>60</x> </widget>
<y>70</y> </item>
<width>133</width> <item row="1" column="1">
<height>20</height> <widget class="SIUnitEdit" name="steps">
</rect> <property name="text">
</property> <string>100</string>
<property name="text"> </property>
<string>100</string> </widget>
</property> </item>
</widget> <item row="2" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_4">
<property name="geometry"> <property name="text">
<rect> <string>Dwell time:</string>
<x>10</x> </property>
<y>70</y> </widget>
<width>47</width> </item>
<height>13</height> <item row="2" column="1">
</rect> <widget class="SIUnitEdit" name="dwell">
</property> <property name="text">
<property name="text"> <string>100ms</string>
<string>Steps:</string> </property>
</property> </widget>
</widget> </item>
<widget class="QLabel" name="label_4"> <item row="3" column="0">
<property name="geometry"> <widget class="QLabel" name="label_5">
<rect> <property name="text">
<x>10</x> <string>Current frequency:</string>
<y>100</y> </property>
<width>47</width> </widget>
<height>13</height> </item>
</rect> <item row="3" column="1">
</property> <widget class="SIUnitEdit" name="current">
<property name="text"> <property name="enabled">
<string>Dwell:</string> <bool>false</bool>
</property> </property>
</widget> <property name="text">
<widget class="SIUnitEdit" name="dwell"> <string>0MHz</string>
<property name="geometry"> </property>
<rect> <property name="readOnly">
<x>60</x> <bool>true</bool>
<y>100</y> </property>
<width>133</width> </widget>
<height>20</height> </item>
</rect> </layout>
</property> </item>
<property name="text"> </layout>
<string>100ms</string>
</property>
</widget>
<widget class="QCheckBox" name="EnabledSweep">
<property name="geometry">
<rect>
<x>60</x>
<y>10</y>
<width>101</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Enabled</string>
</property>
</widget>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>10</x>
<y>130</y>
<width>47</width>
<height>13</height>
</rect>
</property>
<property name="text">
<string>Current:</string>
</property>
</widget>
<widget class="SIUnitEdit" name="current">
<property name="geometry">
<rect>
<x>60</x>
<y>130</y>
<width>133</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>0MHz</string>
</property>
</widget>
</widget> </widget>
</item> </item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</item> </item>
<item> <item>