Results 1 to 6 of 6

Thread: I am brand new and yes I am reading ALOT....

  1. #1
    Join Date
    Sep 2017
    Posts
    12
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default I am brand new and yes I am reading ALOT....

    I finally got my ui portion to work but now I'm trying to figure out how to get the input of a text field to output to a string. Yes I've been looking at examples and everything but Im still completely confused. If someone could just send me an example I would really appreciate it.

  2. #2
    Join Date
    Jan 2017
    Posts
    58
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: I am brand new and yes I am reading ALOT....

    You did not write if you use QLineEdit or QTextEdit, but e.g. for QLineEdit: http://doc.qt.io/qt-4.8/qlineedit.html#text-prop.
    It would really help if you post some code that you tried.

  3. #3
    Join Date
    Sep 2017
    Posts
    12
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: I am brand new and yes I am reading ALOT....

    So i have the basic code for a QWidget setup. Then in the UI i have a QLineEdit named versionText. I am attempting to make the input value in versionText a string so that I can reuse it again and then put it into an output file. That's what I'm having a hard time understanding.

    What I have found so far hasn't worked and I'm trying to understand exactly what I need to setup in order to make that input into a string.


    Added after 39 minutes:


    This is the code I have for source.cpp(aka mainwindow.cpp):

    #include "head.h"
    #include "ui_Start.h"
    #include <QString>
    #include <QLineEdit>


    Class::Class(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Class)
    {
    ui->setupUi(this);
    }

    Class::~Class()
    {
    delete ui;
    }

    void Class:n_caseNumberText_returnPressed()
    {
    caseNumberText->text().toStd
    }


    from the header file:

    #ifndef HEAD_H
    #define HEAD_H

    #include <QMainWindow>
    #include <QString>
    #include <QLineEdit>

    namespace Ui {
    class Class;
    }

    class Class : public QMainWindow
    {
    Q_OBJECT

    public:
    explicit Class(QWidget *parent = 0);
    ~Class();



    private:
    Ui::Class *ui;
    };

    #endif // HEAD_H


    In continues to state that returnPress isn't a member of class Class. And I have no idea how to fix this either but I was giving it a go.
    Last edited by seerofsorrow; 14th September 2017 at 00:43.

  4. #4
    Join Date
    Jan 2017
    Posts
    58
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: I am brand new and yes I am reading ALOT....

    I hope this will help https://www.youtube.com/watch?v=XauEGKUh5Xs
    text() method returns a string (QString).

  5. #5
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: I am brand new and yes I am reading ALOT....

    Quote Originally Posted by seerofsorrow View Post
    In continues to state that returnPress isn't a member of class Class. And I have no idea how to fix this either but I was giving it a go.
    That's because you haven't added a declaration of your slot in your class. So from the compiler's point of view you have implemented a method that does not exist in the class.
    In your class header file add
    Qt Code:
    1. private slots:
    2. void on_caseNumberText_returnPressed();
    To copy to clipboard, switch view to plain text mode 

    Ginsengelf

  6. The following user says thank you to Ginsengelf for this useful post:

    seerofsorrow (18th September 2017)

  7. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: I am brand new and yes I am reading ALOT....

    caseNumberText->text().toStd
    And no idea what this is supposed to do. The line edit's text() method returns a QString, which doesn't have a method or member variable named "toStd". Even if it did, the statement you have written retrieves the text, converts it to something, and then immediately throws it away because you haven't assigned it to anything.

    I think your reading should be expanded to include some basic C++ in addition to Qt.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.