Generally You can not connect signal without parameter to slot with parameter.
Generally You can not connect signal without parameter to slot with parameter.
vuletic (9th December 2014)
That's why most of your connect()'s does not work. The last connect() does not work, IMO, because toggled() signal is defined only for "checkable" buttons (radio buttons, check boxes). If you want a real "toggle button" then make your push button "checkable" first:
myUnderLineButton will behave like toggle button. Now, connect() the toggle() signal. Similarly, you can make other buttons (bold, italic) toggle buttons, too.Qt Code:
myUnderLinebutton->setCheckable(true);To copy to clipboard, switch view to plain text mode
vuletic (9th December 2014)
Hello, Lesiok thanks for that info, and Radek thank you for your solution it works (for underline and italic that is) but for Bold I have problem:
Seems like for some reason toggle is not compatible with "setFontWeight(int)" :
Object::connect: Incompatible sender/receiver arguments
QPushButton::toggled(bool) --> QTextEdit::setFontWeight(int)
connect(myBoldButton,SIGNAL(toggled(bool)),myTextW indow,SLOT(setCurrentFont(QFont::Bold)))<-- nor this
The same as Lesiok has written. You cannot have a bool parameter of the signal and an int parameter of the corresponding slot. Write your own slot for the font weight (with a bool param) and call myTextWindow->setFontWeight(the bool param ?QFont::Bold : QFont::Normal) from it. You can call slots like normal procedures yourself.
Naturally, myTextWindow needs to become a data member of MainWindow. It must not be local in MainWindow ctor. Such a pointer is lost once you leave the ctor.
vuletic (9th December 2014)
What Radek said is exactly the solution, you must write your own slot for the font weight.
cheers!!!
Yeah I made changes, thanks all, and it works very well now, but what I'm wondering now is it possible to make it look "unchecked" on my window like (blue in this picture) http://i.imgur.com/RZPu5cb.png and not red.
http://qt-project.org/forums/viewthread/5482
check this thread out. I think it is what you are looking for!!!
cheers!!!
vuletic (11th December 2014)
Bookmarks