Results 1 to 5 of 5

Thread: Form QLineEdit

  1. #1
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Form QLineEdit

    Simple situation, but I can't find an answer.
    Can anyone please point me to an example of how to setText() of a lineEdit field in a form from a different class? How to reference the form?
    I tried this in the other class cpp:

    Qt Code:
    1. Ui_Form *form;
    2. form -> lineEditField -> setText("ABC");
    To copy to clipboard, switch view to plain text mode 

    Crashes the application

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Form QLineEdit

    How would you do it if you weren't using Qt but only C++?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Form QLineEdit

    How about creating a public method in your ui class that can then access the ui elements on the other classes behalf? By default the ui is private, so only one class can access it. You shouldn't be accessing the ui from multiple classes anyway.

    Remember Model View Architecture, the ui class updates the ui and nothing else. Another class handles the data model, and others handle the data.

  4. The following user says thank you to squidge for this useful post:

    waynew (3rd November 2009)

  5. #4
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Form QLineEdit

    Thanks fatjuicymole - now it makes sense.

  6. #5
    Join Date
    Oct 2009
    Posts
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Form QLineEdit

    Hi, i have created a project(Gui project) and in the main.cpp file i have some sql queries that gets data from a remote sever liekt this;
    if(!query.exec("SELECT..........")){
    qDebug()<<"FAIL";
    }
    while(query.next()){
    QString name = query.value(0).toString();
    qDebug() << name;
    }
    it works well and i have the results printed out like "abdnsh"
    Now in my .ui i have Text Edit. How can i append the sql reults to the Text Edit in my .ui?
    I'm a beginner, please i will appreciate

Similar Threads

  1. Replies: 1
    Last Post: 19th March 2009, 09:41
  2. Replies: 10
    Last Post: 12th February 2009, 07:23
  3. visible main form?
    By triperzonak in forum Newbie
    Replies: 1
    Last Post: 12th June 2008, 09:00
  4. Pointer Question related to QLineEdit
    By ChrisReath in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2008, 15:13
  5. QValidator, regular expressions and QLineEdit
    By hvengel in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2007, 01:25

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.