Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7635843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:31:42+00:00 2026-05-31T07:31:42+00:00

I want to read some variables from a .sh file and pass them to

  • 0

I want to read some variables from a .sh file and pass them to an array (maybe better a vector because i won’t know the lengh?). The variables aren’t environment ones, with other words, i’ll set them per hand.
These variables will be global used by the way.

After this I use them to set a command-, icon- and a namelist for a QListWidget.
I i select an item and click a button it executes the command and displays the result in an QTextEdit.

–> You can see the code here. <–

How can i achieve this and is there a better solution?


EDIT:

Im sorry, but english isn’t my native language so its hard to explain …

At first the files which are:
Dialog.h, Dialog.cpp and Dialog.ui

Then the Files which contains the function:
Query.h and Query.cpp

At least the Script wich i call variables.sh for example.
It contains something like this:

CmdList=("kcmshell4 --list|grep -q kcm_grub2",
         "kcmshell4 --list|grep -q kcm_networkmanagement",
         "which pastebunz",
         "[ -z $ink3_ver ]")

NameList=("kcm_grub2",
          "kcm_networkmanagement",
          "pastebunz",
          "Shellmenu")

IconList=(":/icons/icons/GNU.png",
          ":/icons/icons/networkmanager.png",
          ":/icons/icons/edit-paste.png",
          ":/icons/icons/menu.png")

I dont know the length or content of these. So i should use QVector right?

The Query function is called via a button from the Dialog Ui.

Now i must read the variables from variables.h (this should be done at programstart …).

for (int i = 0; i < ${#$cmdList[*]}; i++) // where '${#$cmdList[*]}' represents the
{ some magical stuff; }                  //legth or the $CmdList array written in bash ...

Then i must use some loop in my function in Query.cpp like

QVector<QString> vCmdList;
for (int i = 0; i < vCmdList.size(); i++)
{
    vCmdList[i] = CmdList[i];
}

I hope its clearer now because i have no idea how to explain it more precicely.

Thanks for your patience ^^

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:31:43+00:00Added an answer on May 31, 2026 at 7:31 am

    It would probably be easier to use QSettings and an .ini file to store your commands than bash arrays.

    For example:

    [kcm_grub2]
    command=kcmshell4 --list|grep -q kcm_grub2
    icon=:/icons/icons/GNU.png
    
    [kcm_networkmanagement]
    command=kcmshell4 --list|grep -q kcm_networkmanagement
    icon=:/icons/icons/networkmanager.png
    ...
    

    With QSettings::childGroups(), you’ll be able to iterate over all the command names to then read the command and the icon path for each name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my grails application I want to read some values from properties file and
I want to read some nodes of a XML file and show their values
I want to simply read some JSON data from a URL, then turn that
i want to read an html file by using jquery get function, replace some
I have a .txt file having some text. I want to read this file
I want to sent some information through a from, executing a php file that
I want to make a program that will read some number in string format
So I've read some articles about scaling Socket.IO. For various reasons I don't want
I have a situation where I want my program to read in some numbers
I want to interrupt some specific grails domain class events(read,write,delete,update).Is there any hibernate eventlistner

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.