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

  • Home
  • SEARCH
  • 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 511667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:14:25+00:00 2026-05-13T07:14:25+00:00

I have the following code: #!/usr/bin/env python import sys from PyQt4 import QtGui, QtCore

  • 0

I have the following code:


#!/usr/bin/env python

import sys
from PyQt4 import QtGui, QtCore

class SimfilePanel(QtGui.QWidget):
  '''This class provides the simfile panel shown on the right side of the main window.'''
  def __init__(self, parent=None):
    '''Load song info here.'''
    QtGui.QWidget.__init__(self, parent)

    ## Make widgets.
    # Pane with simfile information.
    simfileInfoPane = QtGui.QWidget()
    simfileInfoPane.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
    simfileInfoGrid = QtGui.QGridLayout()
    simfileInfoPane.setLayout(simfileInfoGrid)

    simfileInfoScrollArea = QtGui.QScrollArea()
    simfileInfoScrollArea.setWidget(simfileInfoPane)
    #if DEBUG: simfileInfoScrollArea.setBackgroundRole(QtGui.QPalette.Dark);

    # This will change
    labels = []
    textfields = []
    for i in range(0,20):
      labels.append( QtGui.QLabel("Label "+str(i)) )
      textfields.append( QtGui.QLineEdit() )
      labels[i].setBuddy(textfields[i])
      simfileInfoGrid.addWidget(labels[i], i, 0)
      simfileInfoGrid.addWidget(textfields[i], i, 1)

    ## Put widgets in a grid layout.
    mainvbox = QtGui.QVBoxLayout()
    mainvbox.addWidget(simfileInfoScrollArea)
    self.setLayout(mainvbox)


# Standalone testing
if __name__ == "__main__":
  app = QtGui.QApplication(sys.argv)
  panel = SimfilePanel()
  panel.show()
  sys.exit(app.exec_())

I can’t get anything that I’m putting into the simfileInfoGrid to display! They’ll display if I leave out the scroll area, but I need the scroll area as I will have a lot of fields to edit in the final version and I don’t want to stretch the entire window over the screen.

As you see I’ve tried to add a size policy to simfileInfoPane, but it doesn’t seem to affect anything. The area that’s supposed to contain my pane stays empty!

  • 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-13T07:14:25+00:00Added an answer on May 13, 2026 at 7:14 am

    Add the pane to the scroll area after you’ve added all the grid’s contents. In particular you need to call QScrollArea.setWidget after you have finished creating the widget you add.

    I don’t know exactly why this is the problem, but I do know that I tend to initialize widgets “bottom-up”: I finish adding all the contents of a sub-layout before I ever add it to a parent layout. I believe this is Qt optimizing order of rendering but I could be wrong about that.

    The code below is a patch, mostly so you can see where the one-line change is.

        diff -u 1848547.py  tmp2.py
    --- 1848547.py  2009-12-04 11:19:09.000000000 -0800
    +++ tmp2.py 2009-12-04 11:34:58.000000000 -0800
    @@ -19,7 +19,6 @@
         simfileInfoPane.setLayout(simfileInfoGrid)
    
         simfileInfoScrollArea = QtGui.QScrollArea()
    -    simfileInfoScrollArea.setWidget(simfileInfoPane)
         #if DEBUG: 
         simfileInfoScrollArea.setBackgroundRole(QtGui.QPalette.Dark)
    
    @@ -33,6 +32,8 @@
           simfileInfoGrid.addWidget(labels[i], i, 0)
           simfileInfoGrid.addWidget(textfields[i], i, 1)
    
    +    simfileInfoScrollArea.setWidget(simfileInfoPane)
    +
         ## Put widgets in a grid layout.
         mainvbox = QtGui.QVBoxLayout()
         mainvbox.addWidget(simfileInfoScrollArea)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 296k
  • Answers 296k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Some processors have two types of pointers, a near pointer… May 13, 2026 at 7:07 pm
  • Editorial Team
    Editorial Team added an answer The encrypted private key is a blob. PGP usually stores… May 13, 2026 at 7:06 pm
  • Editorial Team
    Editorial Team added an answer I modified the user that the IIS App Pool is… May 13, 2026 at 7:06 pm

Related Questions

I have the following code that is attempting to start each of the commands
I have several buttons in various sizers and they expand in the way that
In most programming environments it's clear how the code is distributed into several parts
I have the following code that tries to tie arrays to files. Except, when
Hi I have the following code: - (IBAction)runTask:(id)sender { NSTask *proc; NSPipe *output; NSData

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.