Inputting Line with specified length (Ortho)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Inputting Line with specified length (Ortho)

TimzPilot
Is there a way that LibreCAD line inputting the same way as AutoCAD does, as it seems a lot quicker with that method than LibreCAD's slow method of entering line length.

Example as per this link https://www.youtube.com/watch?v=3eYHQ8c-isM

So you get the idea?  Any tips, please?  If there is an add-on or extension that does that, can you please point me to this link?

Many thanks ever so much.   (I'm a newbie to LibreCAD and liking it more).

Reply | Threaded
Open this post in threaded view
|

Re: Inputting Line with specified length (Ortho)

TimzPilot
When I dared to try ChatGPT to create a Qt code in an attempt to perform as per above subject.  Here is the code:

#include <QtWidgets>

class LineLengthDialog : public QDialog
{
    Q_OBJECT

public:
    explicit LineLengthDialog(QWidget *parent = nullptr)
        : QDialog(parent)
    {
        // Create the line edit widget
        lineEdit = new QLineEdit(this);

        // Create the OK and Cancel buttons
        QPushButton *okButton = new QPushButton("OK", this);
        QPushButton *cancelButton = new QPushButton("Cancel", this);

        // Create the layout
        QHBoxLayout *layout = new QHBoxLayout;
        layout->addWidget(lineEdit);
        layout->addWidget(okButton);
        layout->addWidget(cancelButton);

        // Set the layout for the dialog
        setLayout(layout);

        // Connect the button signals to slots
        connect(okButton, &QPushButton::clicked, this, &QDialog::accept);
        connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject);

        setWindowTitle("Enter Line Length");
    }

    QString getLineLength()
    {
        return lineEdit->text();
    }

private:
    QLineEdit *lineEdit;
};

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    LineLengthDialog dialog;
    if (dialog.exec() == QDialog::Accepted) {
        QString lineLength = dialog.getLineLength();
        // Use the entered line length as needed
        qDebug() << "Line length entered: " << lineLength;
    }

    return app.exec();
}

#include "main.moc"

Then ChatGPT says the following comments:

This code creates a custom dialog (LineLengthDialog) with a line edit (QLineEdit) for the user to enter the line length. It also includes OK and Cancel buttons. When the user clicks the OK button, the entered line length is retrieved from the line edit and can be used as needed.

Please note that this is just a basic example, and you may need to adapt it to integrate with LibreCAD based on your specific requirements.

++ END


No Idea whether this would work or not as I'm no expert on Qt programming.  Anyone out there to try it out or is ChatGPT unreliable?