Results 1 to 5 of 5

Thread: &arg1

  1. #1
    Join Date
    Apr 2015
    Location
    My home is in beautiful North Carolina.
    Posts
    10
    Qt products
    Qt5
    Platforms
    Windows

    Cool &arg1

    void test_Dialog:n_SaveUpdateComboBox_activated(const QString &arg1)
    {
    QString myarg;
    myarg = ui->SaveUpdateComboBox->currentText();

    if (myarg == "Update Work Order"){
    ui->label_status->setText("Updating the Work Order table.....");
    }
    I am going to use a combobox to save/update to different database tables.
    I'm getting a warning that tells me the arg1 option in the above test_Dialog line above is not being used.
    (unused parameter arg1) is the warning.

    My question is how do I use these parameters? I have tried myarg = &arg1; but that gives an error.

    Thanks for your time and help on this matter, it will be appreciated! :-)

    Please excuse the red-lipped smiley face in the text, if you do not see one I'm not seeing thing it was in the preview of this post.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: &arg1

    Quote Originally Posted by collycrk View Post
    My question is how do I use these parameters? I have tried myarg = &arg1; but that gives an error.
    myarg is of type "QString", the expression on the right hand side of the = is of type "QString*" (pointer to QString) due to using the & operator to get the address of "arg1".
    There is no automatic conversion from "QString*" to "QString" so the compiler cannot accept this assignment.

    You have several options:

    1) remove the argument
    2) remove the argument name
    3) use Q_UNUSED(arg1) to slience the warning
    4) use the argument instead of a local variable
    5) use the argument (not its address) to initialize the local variable instead of getting the value from the combo box.

    Cheers,
    _

  3. #3
    Join Date
    Apr 2015
    Location
    My home is in beautiful North Carolina.
    Posts
    10
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: &arg1

    Thanks anda_skoa. :-)
    Your answers 4 and 5 I do not know how to do. Would you give me a code sample?
    Also any advise concerning the 'Qt best practice' way of doing this would help as well.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: &arg1

    Quote Originally Posted by collycrk View Post
    Your answers 4 and 5 I do not know how to do. Would you give me a code sample?
    for (4)
    Qt Code:
    1. if (arg1 == "Update Work Order"){
    To copy to clipboard, switch view to plain text mode 
    for (5)
    Qt Code:
    1. QString myarg = arg1;
    To copy to clipboard, switch view to plain text mode 

    Quote Originally Posted by collycrk View Post
    Also any advise concerning the 'Qt best practice' way of doing this would help as well.
    My first suggestion would be to not rely on the text displayed in the combo box but the index.
    The index is numerical and will be the same for the respective entry, while the text is likely subjcet to translation.

    Another suggestion is to not use the "connect by name" feature, which I guess you currently do (the slot name suggests that).
    Explicit connect() is way more robust against changes in the designer part of the application.

    Cheers,
    _

  5. #5
    Join Date
    Apr 2015
    Location
    My home is in beautiful North Carolina.
    Posts
    10
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: &arg1

    Update to this thread.
    Thanks again for your instructions.
    The coding is coming along well with your help.

    Thanks again.
    This thread is solved!!

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.