Results 1 to 2 of 2

Thread: Need some help figuring out a code snippet.

  1. #1
    Join Date
    Oct 2015
    Posts
    35
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11
    Thanks
    11

    Default Need some help figuring out a code snippet.

    Hello all,

    I'm trying to understand how the following code that got generated in ui_mainwindow.h file. Can someone please help me understand how it's achieved. I'm trying to build similar application and I'm using qt4.x with c++. Thanks in advance.

    Qt Code:
    1. class Ui_MainWindow
    2. {
    3. public:
    4. QLineEdit *filename_input;
    5. QLabel *current_logfile_label;
    6. ...
    7.  
    8. void setupUi(QMainWindow *MainWindow)
    9. {
    10. filename_input = new QLineEdit(centralWidget);
    11. filename_input->setObjectName(QString::fromUtf8("filename_input"));
    12. filename_input->setGeometry(QRect(20, 390, 291, 31));
    13. current_logfile_label = new QLabel(centralWidget);
    14. current_logfile_label->setObjectName(QString::fromUtf8("current_logfile_label"));
    15. current_logfile_label->setGeometry(QRect(20, 455, 421, 21));
    16.  
    17. ...
    18. }
    To copy to clipboard, switch view to plain text mode 

    I have the following code snippet for LineEdit and check box, in mainwindow.cpp file

    Qt Code:
    1. void MainWindow::on_filename_input_editingFinished()
    2. {
    3. file_increment=0;
    4. QString text;
    5. text=ui->filename_input->text();
    6.  
    7. QString s = QString::number(file_increment);
    8.  
    9. filename = "/logs/" + QString(text) + "_" + s + ".csv";
    10.  
    11. ui->current_logfile_label->setText(filename);
    12.  
    13. }
    14.  
    15. void MainWindow::on_logging_clicked(bool checked)
    16. {
    17. logging_flag=checked;
    18. if(logging_flag)
    19. {
    20. file_increment++;
    21. }
    22. QString text;
    23. text=ui->filename_input->text();
    24.  
    25. QString s = QString::number(file_increment);
    26.  
    27. filename = "/logs/" + QString(text) + "_" + s + ".csv";
    28. ui->current_logfile_label->setText(filename);
    29. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Need some help figuring out a code snippet.

    The ui_xxx.h file is generated by uic from an xxx.ui file. Generally this is arranged by listing the ui file in the FORMS variable of your qmake PRO file. There is also some related setup stuff in the MainWindow consuctor.

  3. The following user says thank you to ChrisW67 for this useful post:

    rookee (11th November 2015)

Similar Threads

  1. [Snippet] QSqlTableModel to CSV Export
    By ottoshmidt in forum Qt Programming
    Replies: 3
    Last Post: 13th June 2011, 02:35
  2. Figuring out what date is more recent than the other?
    By hakermania in forum Qt Programming
    Replies: 6
    Last Post: 20th March 2011, 18:58
  3. Need help figuring out how to paint graphicsRectItems correctly
    By lightning2911 in forum Qt Programming
    Replies: 1
    Last Post: 6th May 2010, 08:39
  4. figuring out who's holding up
    By baray98 in forum General Programming
    Replies: 4
    Last Post: 7th December 2007, 19:29
  5. HPGL PLT code snippet?
    By CuCullin in forum KDE Forum
    Replies: 1
    Last Post: 7th February 2006, 22:17

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
  •  
Qt is a trademark of The Qt Company.