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 6620403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:05:43+00:00 2026-05-25T21:05:43+00:00

So I am writing a Qt GUI for some scientific software and I have

  • 0

So I am writing a Qt GUI for some scientific software and I have QSpinBoxes and QDoubleSpinBoxes for a quantities that user should set the units of. Because I have several of these spinbox-combobox pairs in a row I think it would be least confusing to have the ComboBox on the right fused to the SpinBox on the left.

I have attempted this with stylesheets but I am losing the plastique style when I do this.

What would be a [preferably non-kludgy] way to do this?

Thanks,

Andreas

  • 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-25T21:05:43+00:00Added an answer on May 25, 2026 at 9:05 pm

    If by fused you mean that distance between spinbox and combobox should be zero, then you should create QProxyStyle descendant, reimplement styleHint to return -1 if asked for QStyle::PM_LayoutHorizontalSpacing, and declarie a slot called layoutSpacingImplementation (read QStyle documentation) that is recieving both widget types (as representing them enums).

    MyClass::layoutSpacingImplementation( QSizePolicy::ControlType control1, 
                                          SizePolicy::ControlType control2, 
                                          Qt::Orientation orientation,
                                          const QStyleOption * option = 0,
                                          const QWidget * widget = 0 ) const
    {
        if (orientation == Qt::Horizontal &&
            ((control1 == QSizePolicy::SpinBox && control2 == QSizePolicy::ComboBox) || 
             (control2 == QSizePolicy::SpinBox && control1 == QSizePolicy::ComboBox)))
                   return 0;
    
        int spacing = baseStyle()->styleHint(QStyle::PM_LayoutHorizontalSpacing);
        if (spacing >= 0) return spacing;
        return baseStyle()->layoutSpacing(control1, control2, orientation, option, widget);
    }
    

    Then you set this style for widget those fused items lay on, using it’s previous style as base style.

    This will fuse all those elements together, so it would be best if you added some additional spaces between elements that shouldn’t be fused. That is a small problem, but unfortunately documentation does not state which control describes left or right control (which i guess means that spaces are supposed to be ordering-independent), so there is no other way to achieve it.

    EDIT:

    Just seen posted image. There is no such control in standard qt, and achieving it by typical means is rather unlikely. You might try to create your own layout class or your own QWidget descendant, which will have your spinbox partially covering combobox (covering left round edges part to be exact), this way creating illusion of fusing. This however might look ugly if user uses style with wider edges of combobox, which will “look out” on the side of a sping box. This is quick and veeeeeery ugly workaround.

    Apart from that I think the only option you have is to create your own widget – but even using painting functions from QStyle (mostly drawControl I guess) and scraps of code implementing separate QSpingBox and QCombobox this will mean lots and lots of work. Considering that what you want to achieve is simple graphical effect in UI, i would say that this is not worth the effort.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing some data acquisition software and need a gui plotting library that is
I'm writing an application that should supports gui themes. There is no problem with
I have some legacy code that was writing to a NITF file to display
I'm currently writing a little GUI program that does some work and exits afterwards.
I'm having some trouble writing a GUI in Java that can interact with Tcl
I'm writing a small GUI app that contains some editor functionality, and something that
I am writing an app that requires the user to enter some data into
I'm writing simple GUI using wxPyhon and faced some problems. My application does simple
I'm writing a GUI application that regularly retrieves data through a web connection. Since
I'm writing a GUI tool using PowerShell that is able to do most AD

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.