Hold on... the code above suggests you don't know how to use layouts. Is that true? Can you show us the definition of your tag cloud widget?
Hold on... the code above suggests you don't know how to use layouts. Is that true? Can you show us the definition of your tag cloud widget?
Well, yes I am learning, and have been looking at different forum threads and QT documentation to understand why it is not working in my application, and if I am getting the order wrong or missing out on calling cetain settings.
So, yes, I am not 100% comfortable in the way the layouts work, but am eager to learn the right approach.
I have put snippets of what my code looks like hence it might not be complete.
The mainWidget inherits from another user-defined class (which has some customised functions ) and this in turn inherits from QWidget
ie. mainWidget--> myCustomisedClass->QWidget
Thank you once again for your patience.
I don't care what it is derived from. I only care if it has a proper layout or not. Please provide the full unmodified contents of the constructor.
There is no layout specified in the constructor.
I tried implementing layouts in the ui, and have enclosed them (both ui's: before and after my changes)
- To give you additional information of this Window. It has an option of either viewing words as a list (QListWidget) or as a tag cloud (QWidget)
Before
- In the UI file, there is only the QlistWidget added , there is no layout present. (attachment: tagCloud-before.ui)
- But when the application runs for the listWidget the scrollbar appears when needed.
- the tag cloud widget is added at runtime.
After
- I made modifications to the ui file (tagCloud-after.ui), by enclosing the QListWidget in a ScrollArea.
- I put them in a grid-layout, as when I tried other layouts the QListWidget was not expanding as the window is resized.
Question: Is this the correct layout to use? If not, if you have just one widget in a scrollArea, which is the preferred layout?
- at runtime I tried to hookup the tagcloud to the scrollArea
The application starts to run but hangs after awhile.Qt Code:
Ui::TagCloud ui_tagCloud; ui_tagCloud.scrollAreaWords->setWidget(tagCloudDisplay);To copy to clipboard, switch view to plain text mode
Is this a good approach?
The one "after" is better. But still, I was asking about your tag cloud (tagCloudDisplay) and not the scroll area window.
Thanks Wyosta.
In reply to your questions:
- tagCloudDisplay is a member variable.
- Details are as follows
Class 1 : MyApplication
Class 2: WordsManager (inherits directly from QObject)Qt Code:
void MyApplication::createTagWindow() { TagWindowWidget* tagWindow = new TagWindowWidget; // This class inherits from a customised class which in turn inherits from QObject Ui::TagCloud ui_TagCloud; // This is the ui attached ui_tagCloud.setupUi(tagWindow ); }To copy to clipboard, switch view to plain text mode
Qt Code:
{ WordsDisplay *wordsDisplayWindow = new WordsDisplay(tagCloud, wordList) }To copy to clipboard, switch view to plain text mode
The WordsDisplay class structure is as follows:
Qt Code:
{ Q_OBJECT protected: QWidget* tagCloudDisplay; QListWidget* wordListDisplay; : : }To copy to clipboard, switch view to plain text mode
- I am trying to associate the 'scrollArea' in the ui to the tagCloudDisplay. Would this be the solution?
- How can I do this with the structure I have? As I am not able to retrieve the ui.scrollArea after the tagCloudDisplay is instantiated
We're not getting anywhere...
I'm asking you to present your code because I want to have a look at it, not because I want to steal something from you. If you want me to help you, you have to provide the code I ask you for, not the one you feel like sharing at the moment.
I need to know how the tag cloud is composed. It probably doesn't have a layout applied and I'm pretty certain you didn't reimplement sizeHint() for your widget. Therefore the widget has no real size and will not make the scroll area have scrollbars ever.
Furthermore please read this: Using a Designer .ui File in Your Application - please follow one of the recommended approaches.
Bookmarks