Find the answer to your Linux question:
Results 1 to 6 of 6
char ProjectSniffer::GetDevice() { QByteArray bytes = ui->comboBoxDev->currentText().toAscii().data(); char *Dev; QString devQ = ui->comboBoxDev->currentText(); Dev = (char)devQ; return Dev; } How can i do that right?...
  1. #1
    Just Joined!
    Join Date
    Oct 2009
    Posts
    13

    Qt QString to char

    char ProjectSniffer::GetDevice()
    {
    QByteArray bytes = ui->comboBoxDev->currentText().toAscii().data();

    char *Dev;

    QString devQ = ui->comboBoxDev->currentText();
    Dev = (char)devQ;

    return Dev;
    }

    How can i do that right?

  2. #2
    Just Joined! djap's Avatar
    Join Date
    Jul 2005
    Location
    Not so sure anymore...
    Posts
    97
    How about
    Code:
    char* ProjectSniffer::GetDevice()
    {
    char *Dev = ui->comboBoxDev->currentText().toAscii().data();
    return Dev;
    }
    or just
    Code:
    char* ProjectSniffer::GetDevice()
    {
    return ui->comboBoxDev->currentText().toAscii().data();
    }
    I suppose your function should be returnin pointer (char*) not just character (char)?

  3. #3
    Just Joined!
    Join Date
    Oct 2009
    Posts
    13
    Quote Originally Posted by djap View Post
    How about
    Code:
    char* ProjectSniffer::GetDevice()
    {
    char *Dev = ui->comboBoxDev->currentText().toAscii().data();
    return Dev;
    }
    or just
    Code:
    char* ProjectSniffer::GetDevice()
    {
    return ui->comboBoxDev->currentText().toAscii().data();
    }
    I suppose your function should be returnin pointer (char*) not just character (char)?
    Thx u
    Sry for this stupid Questions but i am a beginner

  4. #4
    Just Joined! djap's Avatar
    Join Date
    Jul 2005
    Location
    Not so sure anymore...
    Posts
    97
    Quote Originally Posted by MonsterreactioN View Post
    Thx u
    Sry for this stupid Questions but i am a beginner
    There's no such thing as a stupid question

  5. #5
    Just Joined!
    Join Date
    Oct 2009
    Posts
    13

    return C struct

    How can i return a C struct in a Qt Function??

  6. #6
    Just Joined! djap's Avatar
    Join Date
    Jul 2005
    Location
    Not so sure anymore...
    Posts
    97
    Same way as you would return it in C-function.
    In case you're not familiar with how to do it you could look in to example 6.1 in here:
    The C Book — Structures

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...