You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Wednesday, May 11th 2005, 10:40am

pixmap for enable and disable button??????

hi all
I have buttons in my application. I have also take icons +text for each button. But problem is that when I disable the button the icon appears as black. If i want to take two images one for enable button and another for disable button then how can i do this.


Thanks and Regards

zlatko

Professional

  • "zlatko" is male

Posts: 728

Location: Ukraine,Lviv

Occupation: programmer

  • Send private message

2

Wednesday, May 11th 2005, 10:54am

try read the docs about QIconSet
a life without programming its alike empty bottle 8)

3

Wednesday, May 11th 2005, 3:23pm

hi all
plz help i tried the docs

thanks and regards

zlatko

Professional

  • "zlatko" is male

Posts: 728

Location: Ukraine,Lviv

Occupation: programmer

  • Send private message

4

Wednesday, May 11th 2005, 3:37pm

try something like that

Source code

1
2
3
4
5
6
QIconSet *is = new QIconSet();

is->setPixmap("enable.png",Automatic,Enabled);
is->setPixmap("disable.png",Automatic,Disabled);

button->setIconSet( is );
a life without programming its alike empty bottle 8)

5

Thursday, May 12th 2005, 8:20am

hi all

QIconSet *is = new QIconSet();
QPixmap *cancel_enable= new QPixmap("images/cancel_enable.png");
is->setPixmap(*cancel_enable,QIconSet::Automatic,QIconSet::Active,QIconSet::On);
CancelButton->setIcon(is);


But it gives following error
error: no matching function for call to `QPushButton::
setIconSet(QIconSet*&)'


Thanks in advance

dimitri

Professional

  • "dimitri" is male

Posts: 1,311

Occupation: Engineer

  • Send private message

6

Thursday, May 12th 2005, 8:28am

Try this instead:

Quoted

QIconSet is;

is.setPixmap("enable.png",Automatic,Enabled);
is.setPixmap("disable.png",Automatic,Disabled);

button->setIconSet( is );

zlatko

Professional

  • "zlatko" is male

Posts: 728

Location: Ukraine,Lviv

Occupation: programmer

  • Send private message

7

Thursday, May 12th 2005, 10:30am

or

Source code

1
button->setIconSet( *is );




:))
a life without programming its alike empty bottle 8)

8

Thursday, May 12th 2005, 2:42pm

hi all

I have now no error in the following code but the icon is not appear on the button. I write the following code in the Init()


QIconSet *is = new QIconSet();

is->setPixmap("images/cancel_enable.png",QIconSet::Automatic,QIconSet::Normal,QIconSet::On);
CancelButton->setIconSet( *is );



What should i do?

Thanks and Regards

zlatko

Professional

  • "zlatko" is male

Posts: 728

Location: Ukraine,Lviv

Occupation: programmer

  • Send private message

9

Thursday, May 12th 2005, 2:52pm

you should look up at all fist post in this thread
a life without programming its alike empty bottle 8)

10

Friday, May 13th 2005, 1:48pm

hi all

In starting i have take icon of buttons at design time but my requirement is to take two icons for each button, One at the time when the button is enabled and other when the button is disabled.

but through coding i am till now not able to take icon for enable or disable button. i tried lot but in vain. Even there is no error when i write following code in the init() of my form on which i taken the buttons.

QIconSet *is = new QIconSet();

is->setPixmap("images/cancel_enable.png",QIconSet::Automatic,QIconSet::Normal,QIconSet: n);
CancelButton->setIconSet( *is );

Plz sought out my problem.

Thanks in advance

11

Monday, May 16th 2005, 1:42pm

hi all

Plz reply me

Thanks and regards

12

Monday, May 16th 2005, 8:45pm

Try something like this:

Source code

1
2
3
4
5
6
7
8
    QAction *debugAct = new QAction(tr("Debug Mode On/Off"), tr("Ctrl+Alt+D"), this);
    QIconSet debugIconSet;
    debugIconSet.setPixmap(QPixmap::fromMimeSource("./images/debug_icon.png"), QIconSet::Automatic, QIconSet::Active, QIconSet::On);
    debugIconSet.setPixmap(QPixmap::fromMimeSource("./images/debug_off_icon.png"), QIconSet::Automatic, QIconSet::Active, QIconSet::Off);
    debugAct->setIconSet(debugIconSet);
    debugAct->setStatusTip(tr("Toggle Debug Mode On/Off"));
    debugAct->setToggleAction(true);
    connect(debugAct, SIGNAL(activated()), this, SLOT(setDebugMode()));


but in your case play with the disabled flags. I wanted my icons to switch when the button is pressed not taking whether it is disabled into account.

This should get you closer to what you want.