how to change a value data in a variable

41 views
Skip to first unread message

Mohamed Saber

unread,
Jan 24, 2026, 4:19:23 AM (9 days ago) Jan 24
to The Ring Programming Language
hello everyone
This code contains setStyleSheet variable (comboStyle) with some values.
 I want to use the same variable in the second combo box, but with some of the values ​​changed.
i want change color and padding as like this

comboStyle=(`QComboBox {padding-left: 20px;color: #000000;selection-background-color: transparent;selection-color: #000000;}

QComboBox QAbstractItemView {color: #000000;selection-background-color: transparent;selection-color: #000000;}`)



my code:

load "guilib.ring"

comboStyle=(`QComboBox {padding-left: 80px;color: #000000;selection-background-color: transparent;selection-color: #000000;}

QComboBox QAbstractItemView {color: #000000;selection-background-color: transparent;selection-color: #000000;}`)


new qApp {


win1 = new qWidget() {


setwindowtitle("Using QComboBox")

setGeometry(100,100,400,400)


new QComboBox(win1) {


// If you want to center the selected item

//setEditable(True)

// lineEdit().setAlignment(Qt_AlignHCenter)

// lineEdit().setReadOnly(True)


setGeometry(150,100,200,30)

alist = ["one","two","three","four","five"]

for x in aList

additem(x,0)

next


// Center items in the drop list

centerComboItems(self)

setStyleSheet(comboStyle)


}


new QComboBox(win1) {


// If you want to center the selected item

//setEditable(True)

// lineEdit().setAlignment(Qt_AlignHCenter)

// lineEdit().setReadOnly(True)


setGeometry(150,200,200,30)

alist = ["one","two","three","four","five"]

for x in aList

additem(x,0)

next


// Center items in the drop list

centerComboItems(self)

setStyleSheet(comboStyle)


}

show()

}


exec()

}


func centerComboItems oComboBox


Qt_TextAlignmentRole = 7

property = new QVariant2(Qt_AlignHCenter)


oComboBox {

for t=1 to count()

setItemData(t-1,property, Qt_TextAlignmentRole);

next

}


Mahmoud Fayed

unread,
Jan 24, 2026, 4:22:01 PM (8 days ago) Jan 24
to The Ring Programming Language
Hello Mohammed

(1) You can use the SubStr() function


(2) Another option is using Print2Str() function


Suggestions:

1- Study the basics of the Ring language before trying to develop an app


2- For quick answers ask AI like Claude Code

Greetings,
Mahmoud

Mohamed Saber

unread,
Jan 25, 2026, 8:05:46 AM (8 days ago) Jan 25
to The Ring Programming Language
i will try to convert the code to function and use parameters 
thank you

Mahmoud Fayed

unread,
Jan 25, 2026, 8:11:08 AM (8 days ago) Jan 25
to The Ring Programming Language
Hello Mohammed

You are welcome :D

Greetings,
Mahmoud

Reply all
Reply to author
Forward
0 new messages