Results 1 to 2 of 2

Thread: Silly Question/A very silly question

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

    Default Silly Question/A very silly question

    I'm trying to make a directory in my system based off of input from the ui and I can't get the QString to take another QString injected into it. I'm trying to understand how to get that to work. If anybody could give me some insite I'd appreciate it. I have a LineEdit box in my ui called caseNumberText.

    I initilized filename as "C:/Users/Administrator/Qt/"

    My main has no errors in it and is a very basic template. the only problem i'm having with is my classy.cpp file:
    #include "header.h"
    #include "ui_gui.h"
    #include <QTextStream>
    #include <QString>
    #include <QLineEdit>
    #include <QFile>
    #include <QDebug>
    #include <QFileDialog>

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

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

    void Classy::on_caseNumberText_selectionChanged()
    {
    QString caseNumberText = ui->caseNumberText->text();
    QString filename = "C:/Users/Administrator/Qt/"caseNumberText;

    QDir dir(filename);
    if (!dir->exists())
    {
    dir->mkpath(filename);
    }
    else
    {
    qDebug << caseNumberText << "already exsists";
    }

    }

  2. #2
    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: Silly Question/A very silly question

    QString filename = "C:/Users/Administrator/Qt/"caseNumberText;
    How about looking at QString::operator+() or the equivalent QString::append()?

    Qt Code:
    1. QString filename = QString( "C:/Users/Administrator/Qt/" ) + caseNumberText;
    2. // or
    3. QString filename = QString( "C:/Users/Administrator/Qt/" ).append( caseNumberText );
    To copy to clipboard, switch view to plain text mode 

    No silly questions, just silly answers.

    Of course, once you get your string built, Windows probably won't actually let you create a directory under Administrators unless you are running your program with elevated permission. If you just click the icon for Qt Creator / Visual Studio, you aren't running that way, so any program you run from within the IDE or debugger won't have permission either.
    <=== 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.

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

    seerofsorrow (28th September 2017)

Similar Threads

  1. question about xmpp (different question)
    By davinciomar in forum Newbie
    Replies: 9
    Last Post: 6th September 2016, 13:52
  2. Simple and silly question about QWidget
    By dima in forum Qt Programming
    Replies: 3
    Last Post: 2nd December 2010, 09:14
  3. Replies: 2
    Last Post: 4th July 2010, 21:44
  4. silly undefined refrence to main
    By quickNitin in forum Newbie
    Replies: 3
    Last Post: 16th November 2006, 09:41
  5. silly array element counter..
    By ct in forum General Programming
    Replies: 4
    Last Post: 3rd March 2006, 15:50

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.