Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 917415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:12:28+00:00 2026-05-15T18:12:28+00:00

I need small help, I’m using class Qslider from qt, how can I get

  • 0

I need small help, I’m using class Qslider from qt, how can I get the number of the current position of the cursor (with which function I can do that) thanks in advance

edited

I want to implement one thing: when I reach the max of the interval I want to quit, how can I do this with slot and signal?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T18:12:29+00:00Added an answer on May 15, 2026 at 6:12 pm

    I am assuming you want the value of the slider?

    int QSlider::value ()
    

    I looked at the code in your other post and this is what I came up with after cleaning it up:

    main.cpp

    #include <QApplication>
    #include "mywidget.h"
    
    int main(int argc, char *argv[])
    {
     QApplication app(argc, argv);
     MyWidget widget;
     widget.show();
     return app.exec();
    }
    

    mywidget.h

     #ifndef MYWIDGET_H
     #define MYWIDGET_H
     #include <QWidget>
     #include <QObject>
     include <QPushButton>
     #include <QSlider>
    
     class MyWidget : public QWidget
     {
      Q_OBJECT
      public:
    MyWidget(QWidget *parent = 0);
    ~MyWidget(){};
      public slots:
    void getSliderValueAndQuit();
      private:
     QPushButton *quit;
     QSlider *slider;
     };
    
     #endif // MYWIDGET_H
    

    myWidget.cpp

     #include "mywidget.h"
     #include <QWidget>
     #include <QObject>
     #include <QApplication>
     #include <QFont>
     #include <QLCDNumber>
     #include <QPushButton>
     #include <QSlider>
     #include <QVBoxLayout>
    
     MyWidget::MyWidget(QWidget *parent) :
     QWidget(parent)
     {
    quit = new QPushButton(tr("Quit"));
    quit->setFont(QFont("Times", 18, QFont::Bold));
    
    QLCDNumber *lcd = new QLCDNumber(3);
    lcd->setSegmentStyle(QLCDNumber::Flat);
    
    slider = new QSlider(Qt::Horizontal);
    slider->setRange(0, 999);
    slider->setValue(0);
    
    connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));
    
    connect(slider, SIGNAL(valueChanged(int)),lcd, SLOT(display(int)));
    connect(slider,SIGNAL(sliderReleased()), SLOT(getSliderValueAndQuit()));
    
    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(quit);
    layout->addWidget(lcd);
    layout->addWidget(slider);
    setLayout(layout);
     }
    
     void MyWidget::getSliderValueAndQuit(){
    if(slider->value() == slider->maximum())
        close();
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need small help. I have 2 lists( say A and B) which have
I need a small program that can calculate the checksum from a user input.
I need some help with my xpath query. I can get this code to
I need a small help with slots . class bstream(object): __slots__ = ['stream'] stream
Im working on a small project which has a textarea and i need help
I have given a diagram of my current small problem that I need help
I need some help on using two open sources scripts for a small project.
Need some small help with some SQL. I am using a VARCHAR value to
i need a small help.. i am looping over objects which are in db
Please i need your help with a small issue i'm having. I'm using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.