Results 1 to 4 of 4

Thread: i am new... please help

  1. #1
    Join Date
    Sep 2009
    Posts
    64

    Default i am new... please help

    I am trying to make a simple RGB value setter with some Spin Boxes and Vertical Scrolls... but i want it to be more interactive than just that. I want there to be a color box... or something that's actual color value (R,G,B) will change with the changes from the vertical scrolls... how can i do this? Again I am very very new at this stuff so please, any help is greatly appreciated. Basically, Im looking for something to set the color of a form or whatever that can call a "getValue" or something similar from the spin box or scroll

    thanks again.

    also, to take this one step further... is there a way, in QT designer, to create a window or widget, and, while in the designer, look at the actual code that is being created and edit it?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: i am new... please help

    Quote Originally Posted by Slewman View Post
    I am trying to make a simple RGB value setter with some Spin Boxes and Vertical Scrolls... but i want it to be more interactive than just that. I want there to be a color box... or something that's actual color value (R,G,B) will change with the changes from the vertical scrolls... how can i do this? Again I am very very new at this stuff so please, any help is greatly appreciated. Basically, Im looking for something to set the color of a form or whatever that can call a "getValue" or something similar from the spin box or scroll
    • learn basic C++
    • have a look at the signal slot mechanism of Qt

    thanks again.

    also, to take this one step further... is there a way, in QT designer, to create a window or widget, and, while in the designer, look at the actual code that is being created and edit it?
    No, the c++-code is created via uic. so you can't see the code inside the designer. The designer is only for GUI modeling, not for coding.

  3. #3
    Join Date
    Sep 2009
    Posts
    64

    Default Re: i am new... please help

    Its not that I dont know c++, i do, Im trying to do this in the QT Designer before i try to do this simply by programming it. i know there is a function in the spinBox class "int value()" that will return the value in the spinBox, is there anyway to set a background color corresponding to that value?

    i treid addying a style sheet and using spinBox->value() but its not giving me any result. any suggestions?

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: i am new... please help

    you can't do it in the designer. because there is no slot called setRValue() or setGValue() for any widget.

    So you have to manipulate the palette of your "color-widget" by your own. Or write your own widget, providing these slots and write a designer plugin for that color-widget.

    Qt Code:
    1. connect(slider1, SIGNAL(valueChanged(int)), this, slider1changed(int));
    2. //...
    3. ...::slider1changed(int i)
    4. {
    5. QPalette p = colorwidget->palette();
    6. QColor c = p.color(QPalette::Window);
    7. c.setRed(i);
    8. p.setColor(QPalette::Window, c);
    9. colorwidget->setPalette(p);
    10. }
    To copy to clipboard, switch view to plain text mode 
    You can use QSignalMapper to simplyfiy.

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.