[SOLVED] How to hide/show things with a certain widget, and how to show output of terminal in a window?



  • So 1st question is what is this widget?

    !http://i.imgur.com/eiHOL.png(widget)!

    it can hide and show things, it looks very cool.. i could sure hide and show things with a button saying "Details", but i wouldn't be able to have an arrow showing right when hidden and down when visible.. plus a button would be ugly..

    [SOLVED]
    and the 2nd question is how to show output of terminal in a window.. like this:

    !http://i.imgur.com/2Y9Vq.png(widget2)!



  • Anyone? At least for the 1st question?


  • Moderators

    You could use a QCheckBox and change the indicator using a style sheet, I suppose.

    See "here":http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qcheckbox for an example.



  • About the terminal thing:
    Do you want an application-terminal so your application can print some information and receive commands from the user or do you want actual terminal cout/cin with another process?

    If you only want the first, subclass QTextEdit, set the styles accordingly (black background, white text, monospaced font, etc.) and reimplement the key events to allow typing only at the very last line after some prompt, e.g. "/home/leon/$". Further you should add some signals/slots for typical terminal jobs: signal executeCommand(QString) when the user hits return after typing something, slot print(QString) to print a line, slot prompt() to create a new prompt after printing some lines.

    If you want inter-process-communication via cin/cout stream, look at QProcess. You can use it like any of the other QIODevices (e.g. QTcpSocket), read the other processes' cout and append it into a terminal-style text edit as described above.



  • [quote author="mlong" date="1344956843"]You could use a QCheckBox and change the indicator using a style sheet, I suppose.

    See "here":http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qcheckbox for an example.[/quote]

    so this works for me
    @ ui->checkBox->setStyleSheet("QCheckBox::indicator:unchecked {image: url(:/icons/Pictures/unchecked.png);}");
    @

    but what about the image? How can all programms on ubuntu have the same right/down arrow.. where can i find this icon in ubuntu?

    Could i use a QIconfromtheme? if yes which one and how should i modify the above code?



  • It is really a good idea! Thank you.

    [quote author="DerManu" date="1344959009"]About the terminal thing:
    Do you want an application-terminal so your application can print some information and receive commands from the user or do you want actual terminal cout/cin with another process?

    If you only want the first, subclass QTextEdit, set the styles accordingly (black background, white text, monospaced font, etc.) and reimplement the key events to allow typing only at the very last line after some prompt, e.g. "/home/leon/$". Further you should add some signals/slots for typical terminal jobs: signal executeCommand(QString) when the user hits return after typing something, slot print(QString) to print a line, slot prompt() to create a new prompt after printing some lines.

    If you want inter-process-communication via cin/cout stream, look at QProcess. You can use it like any of the other QIODevices (e.g. QTcpSocket), read the other processes' cout and append it into a terminal-style text edit as described above.[/quote]

    Anyone can answer what i said previous?

    [quote author="Leon" date="1345037007"][quote author="mlong" date="1344956843"]You could use a QCheckBox and change the indicator using a style sheet, I suppose.

    See "here":http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qcheckbox for an example.[/quote]

    so this works for me
    @ ui->checkBox->setStyleSheet("QCheckBox::indicator:unchecked {image: url(:/icons/Pictures/unchecked.png);}");
    @

    but what about the image? How can all programms on ubuntu have the same right/down arrow.. where can i find this icon in ubuntu?

    Could i use a QIconfromtheme? if yes which one and how should i modify the above code?[/quote]



  • The arrow is supplied by the OS. In win7 / Vista etc other views are given. The software will show different arrow types for every OS that it is compiled on. If you want it differently you probably need to subclass the QCheckbox and do the paint yourself.
    greetz



  • [quote author="Jeroentje@home" date="1345111036"]The arrow is supplied by the OS. In win7 / Vista etc other views are given. The software will show different arrow types for every OS that it is compiled on. If you want it differently you probably need to subclass the QCheckbox and do the paint yourself.
    greetz[/quote]

    Well u say The arrow is supplied by the OS.. i know that.. but how to do it?
    Should i use a QIconfromtheme? if yes which one and how should i modify the above code?



  • It's unlikely anyone knows something so specific (where some random icon in some random program comes from) here. So you must do the research yourself. For example, you could retrieve all icons with QIcon::fromTheme (see the documentation for all possible icon names) and see if there's your arrow somewhere. Then your program looks like it's part of ubuntu and thus open source. Go find its source code and see where they get the icon from.



  • From here (http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html), they only icon i can see, is go-down, go-next which is not really the one i wanted ( like all the ubuntu apps are using ), but i think it might do..

    I am kinda confused how should i change the code

    @ui->checkBox->setStyleSheet("QCheckBox::indicator:unchecked {image: url(:/icons/Pictures/unchecked.png);}");@

    This won't work:
    @ui->checkBox->setStyleSheet("QCheckBox::indicator:unchecked {image: url(QIcon::fromTheme("go-down"));}");@

    [quote author="DerManu" date="1345112055"]It's unlikely anyone knows something so specific (where some random icon in some random program comes from) here. So you must do the research yourself. For example, you could retrieve all icons with QIcon::fromTheme (see the documentation for all possible icon names) and see if there's your arrow somewhere. Then your program looks like it's part of ubuntu and thus open source. Go find its source code and see where they get the icon from.[/quote]


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.