TextEdit - Vertical Scroll Bar - Disconnect all signals from scroll bar slots



  • I am using a TextEdit widget but I need to control it's vertical scroll bar directly. I don't want the TextEdit widget to do anything with the vertical scroll bar. Is there a way to disconnect all signals from the scroll bar slots?

    I've looked at the "disconnect" documentation, but this disconnects everything connected to an objects signals. Therefore the following disconnects all signals emitted by the scroll bar, but I want to disconnect all signals connected to the slots on the scroll bar:
    [code]
    disconnect(ui->textEdit->verticalScrollBar(), 0, 0, 0);
    [/code]

    The disconnect method cannot be used with the '0' wildcard for the Sender, so I cannot do the following:
    [code]
    disconnect(0, 0, ui->textEdit->verticalScrollBar(), 0);
    [/code]

    If I know what to use as the sender, then I could do something like this:
    [code]
    disconnect(sender, 0, ui->textEdit->verticalScrollBar(), 0);
    [/code]

    Thanks for any guidance you can provide.


  • Moderators

    You could simply hide the default vertical scroll bar using
    @
    widget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    @
    and then put your own manually instantiated scroll bar in its place.



  • True, but this brings up another question.

    I use a Dock widget, with the TextEdit widget inside of it, so that the TextEdit is resized as the user resizes the window.
    [code]
    ui->dockWidget->setWidget(ui->textEdit);
    [/code]

    I couldn't see a way to have two widgets (TextEdit and separate vertical scroll bar) in the Dock widget so that both resized with the window. Do you know a way to do this?

    Thanks again.



  • You could just put them both inside another widget, and put them in a layout together...


Log in to reply
 

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