Dokuwiki¶
Napster error codes¶
2001 Insufficient disk space
2002 File transfer error (wrong size?)
3001 Download license expired
Qt programming¶
Header declarations (.h)¶
Why¶
Declare a function or a class variable. Qt will automatically create the constructor and destructor.
Example¶
private:
Ui::BeamWindow *ui;
QMap<QString, int> base_tl;
private slots:
void minTL();
void minTL2(int);
Code file (.cpp)¶
This is where the magic happens.
Signals and Slots¶
Tip: Put the connections in the form constructor, connections are only active from the point of the code in which they are declared. If they are in the constructor, the connections will be made as soon as the form is created.
New Style (Qt5) Signals and Slots¶
Advantages:
- Easy
- Checks functions parameters are correct at compile-time
Disadvantages:
- Doesn’t work with QML
- Cannot specify function parameters for overloaded functions?
Example:
connect(ui->listWidget, &QListWidget::currentItemChanged, this, &BeamWindow::minTL);
Old Style (Qt4) Signals and Slots¶
Advantages:
- Works with QML
- Can specify function parameters for overloaded functions
- See the function parameters as you have declared them
Disadvantages:
- Checks functions parameters are correct at run-time
- Not as simple as the new style
Example:
connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(minTL2(int)));
QStrings¶
Convert a number into text:
const QString chosen_beam = QString::number(base_tl.value(ui->listWidget->currentItem()->text(), 0));
Spinbox Control¶
Get Value¶
To get the value of the spinbox (as integer):
const int old_min_tl = ui->spinBox->value();
To get the value of the spinbox (as text):
const int old_min_tl = ui->spinBox->text();
Can also obtain the prefix and suffix if one has been applied - refer to manual.
Set Value¶
Set Minimum (as integer?):
ui->spinBox->setMinimum(new_min_tl);
Set both minimum and maximum with setRange(x,y)
ListWidget Control¶
Get Value¶
Get the current item (not necessarily the selected item(s)):
ui->listWidget->currentItem()->text()
Cross-reference current item with dictionary (aka Map):
base_tl.value(ui->listWidget->currentItem()->text(), 0)
The purpose of “,0)” is to use an overloaded function similar to SQL COALESCE - it provides a default output value.
LineEdit Control¶
Get Value¶
Set Value¶
ui->lineEdit->setText(chosen_beam);