Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Return a QString maybe a C++ question
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Return a QString maybe a C++ question

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mr_maddog
    wrote on last edited by
    #1

    Hi
    i wanna return a QString fileName from on_pushButton_clicked() to on_commandLinkButton_clicked()
    With on_pushButton_clicked() i get my filename to open.
    In on_commandLinkButton_clicked() process the file

    What do i have to do. I tried severel snippet from google but i am a complete C++ beginner an have no idea..

    @
    void EngMountStiff::on_pushButton_clicked()
    {
    QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "",tr("Nastran Punch Files (.pch);;ALL Files (.*)"));
    }
    void EngMountStiff::on_commandLinkButton_clicked()
    {
    QString aScript = "print ""+fileName+"\n";";
    .
    .
    .
    }
    @

    Thanks

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Code_ReaQtor
      wrote on last edited by
      #2

      You should define(?) a QString inside your class (header file)

      @class EngMountStiff
      {
      //whatever is added here

      private: //i prefer it private, depends on you
          QString fileName;
      

      }@

      then you may use it in your classes like this:
      @void EngMountStiff::on_pushButton_clicked()
      {
      /Notice the minor change here/
      fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "",tr("Nastran Punch Files (.pch);;ALL Files (.*)"));
      }
      void EngMountStiff::on_commandLinkButton_clicked()
      {
      QString aScript = "print ""+fileName+"\n";";
      .
      .
      .
      }@

      Please visit my open-source projects at https://github.com/Code-ReaQtor.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mr_maddog
        wrote on last edited by
        #3

        That easy?

        Thanks alot....

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved