Can't reach newly made QLCDNumber - c++

I was doing some testing with QTimer, within a bigger project, using Qt. I wanted to increment a value every 10 milliseconds and show that on the GUI.
void MainWindow::on_timeout(){
tmpValue++;
ui->testValue->display(tmpValue);
}
I copypasted a ui for a old project and added some of my own stuff.
I made the QLCDNumber testValue with a tag behind it saying the same. I expected to see the "testValue" int increase quickly but it did nothing. the weird part is when I replace the
ui->testValue->display(tmpValue);
with
ui->lcdThreshold1->display(tmpValue);
It worked as intended, but of course not with the QLCDNumber I wanted
this works for all QLCDNumbers that I have created in the past, just whenever I add a new one it does not work.
Some things worth noting are that it builds and runs without a problem. Also the "lcdThreshold1" from earlier is red the Qt editor, just like the "ui" bit. Whenever I put the new QLCDNumber there, like "testValue", it stays black and is not a option on the autocomplete.
Thanks in advance for your time!
pastebin of the xml file

Related

Qt: QVideoWidget doesn't show up and disables all buttons within application OR extremely slows down the application

To make it clear the question is: Why, when I add a QVideoWidget to my application, all buttons become not clickable, the scrollbars don't work, and the comboboxes as well become not clickable? Is QVideoWidget disabling those functionalities? Or is that maybe (like I read in this SO question) QVideoWidget is extremely slowing down my application, just by being added to the application?
Now the details:
I really hope someone can help me with this. I'm trying to place a QvideoWidget into my desktop application with the following code (nothing special, just like in the tutorials):
// ...
// more code above for other things...
// main video-player widget
video_widget = new QVideoWidget;
video_widget->setMaximumHeight(100); // I could set any size here...this is not the point
video_widget->setMinimumHeight(100);
video_widget->setStyleSheet(STYLE_WIDGET_BG); // same background as the other widgets...
video_widget->setMaximumWidth(100);
video_widget->setMinimumWidth(100);
media_player = new QMediaPlayer(0, QMediaPlayer::VideoSurface);
TV_V_LAYOUT_MAIN_2->addWidget(video_widget); // #define TV_V_LAYOUT_MAIN_2 ui.lvl_4_tv2_h_1 --> this a layout inside another layout...
media_player->setVideoOutput(video_widget);
return; // this function is called inside the MainWindow constructor
So there are the situations:
1) Without adding the videowidget, everything works fine...
2) As soon as I add the QVideoWidget with the code above:
app overview
What happens?
The video player doesn't show up in any way. There should be at least the gray background like the other widgets, but nothing. Yet the buttons position lowers, so I guess the player was inserted...The problem is: all buttons (and I mean ALL buttons within my application) are disabled. So are the comboboxes and the scrollbar. By disabled I mean, when you click them, it doesn't normally "animate" like when a button is cliked, and the scrollbar doesn't scroll...
By the way the QVideoWidget is not places into the same layout as the buttons below. You can see the layout hierarchy here: Layouts with Qt Designer
I guess I'm missing something very simple. Anyone got the solution for me?
INFO: I'm programming with Visual Studio 2013 with Qt Add-In; I use only standard libraries; gstreamer is included in the project as well (nothing implemented yet).
OLD EDIT: it may be that the inserting of the video-widget extremely slows down the application, therefore giving the illusion that the scrollbar and the buttons don't work, just because it takes a lot of time for them to process the user interaction. Is this possible? Any solution for that?
Got the solution:
If your QVideoWidgets or QMediaPlayers extremely slow down your application, all you have to do, if you haven't yet, is to move all (or just the nedeed) Qt dll's into your project folder.
That's very basic, I know, yet that was my problem. Now it works like heaven.

wxDataViewCtrl and DnD

I am using wxWidgets 3.0.2 with Gtk on Linux.
I am trying to make a wxDataViewCtrl a drop target for a drag and drop operation. I derived a class from wxTextDropTarget and then made a call to wxDataViewCtrl::SetDropTarget() to make an instance of this class to be the drop target for the wxDataViewCtrl.
However, nothing happens. Every time I try to drop something on the wxDataViewCtrl, the wxDropSource::DoDragDrop() method returns wxDragCancel. For my custom wxTextDropTarget class, I overrode the OnEnter() method and had it write to stdout "OnEnter()" whenever I entered the wxDataViewCtrl with something to drop, but nothing gets written to stdout.
To test that I am even doing the custom wxTextDropTarget class right and setting up the drop source correctly, I added a wxTextCtrl to my GUI and made that the drop target and everything worked as expected: wxDropSource::DoDragDrop() returned wxDragCopy and "OnEnter()" would get written to stdout when I entered the wxTextCtrl with something to drop.
Does wxDataViewCtrl not support DnD? Or is there something else I am overlooking?
Just thought I'd follow up on my own post in case somebody else runs into the same problem.
After writing a small test program just to test DnD between a control and a wxDataViewCtrl and discovering that it works fine, I went back to my original application and stared at it for a bit longer to try and figure out what was I was doing differently. It turns out that I needed to call SetDropTarget() on the PARENT window of the target wxDataViewCtrl and not the wxDataViewCtrl itself, i.e. my_data_view_ctrl->GetParent()->SetDropTarget(blah blah blah);.
However, I didn't have to do this in my test program, so I thought it was a bit weird. The only difference between my test program and my actual program was that in my actual program, I have the wxDataViewCtrl inside a wxStaticBoxSizer and I think that was problem. I suspect that the wxStaticBox (that the wxStaticBoxSizer uses) was getting the drop notification instead of the wxDataViewCtrl, hence why I needed to set it's SetDropTarget() rather than the wxDataViewCtrl.

QMenu activated multiple times

I was playing around with the Qt demo browser example mentioned here and noticed an anomaly when I tried making a minor change to the bookmark handling code.
My intention was to make the bookmarks in the toolbar open up in a new tab instead of the existing tab. It works perfectly for the bookmarks that are located directly on the bookmarks tab. But the bookmarks inside a folder are the ones which are behaving weirdly.
I modified the BookmarksToolBar::activated SLOT in the bookmarks.cpp to open the url in a new tab instead of existing tab. That's when I noticed that the SLOT is being called multiple times, the count being equal to the number of times the menu is rendered. i.e, the first time a menu item is activated, the SLOT is called once, the next time an item is activated, the SLOT gets called twice and so on.
I thought there must have been multiple signal-slot connections and thus I checked on the BookmarksToolBar::build() method where the signal-slot connection is done and found that the control flow enters the method only once. I am finding it hard to figure out how the SLOT is being called multiple times.
The project is question is an example project 'Tab browser' which comes with Qt and can be accessed by clicking on 'Examples' on the Qt-Creator welcome screen. Thus I did not post any source code here.
Any guidance or help in understanding the cause for this anomaly and possible solutions to fix it would be appreciated.
Found the cause of the problem and solution myself. The root of the problem is in modelmenu.cpp.
Apparently the ModelMenu::createMenu method connects the QMenu::triggered and QMenu::hovered signals to SLOT each time the method is called. The SLOT triggered emits the signal ModelMenu::activated.
Using Qt::UniqueConnection should solve the issue.
Replacing this:
connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(triggered(QAction*)));
connect(menu, SIGNAL(hovered(QAction*)), this, SLOT(hovered(QAction*)));
With this:
connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(triggered(QAction*)),Qt::UniqueConnection);
connect(menu, SIGNAL(hovered(QAction*)), this, SLOT(hovered(QAction*)),Qt::UniqueConnection);
Fixed the problem. Just leaving this here hoping this would help someone in future.

QDialog or QMessageBox show Qt::BusyCursor when added to existing application

I am new to qt and I have an issue I cannot understand.
I have created my own QDialog and now I want to add it to an existing application.
In QT creator, everything works fine but when I add either my custom dialogue or even a
message box to the existing code, something odd happens.
The dialogue works just fine but when I hover over the main area of the dialogue
the icon changes to a Qt::BusyCursor the busy wait icon.
At first I assumed this must be a threading issue but then isn't .exec() suppose to block?
Also when I hover over the title bar or the message box / dialogue, it seems fine i.e it shows a Qt::ArrowCursor, in both cases the dialogue functionally works fine also.
I have tried to set the .setCursor() on both and it did not work still a busy icon.
can anyone give me some hints as to what I might look at to investigate this more.
Thanks a lot!!!
I can suggest you to use
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
and reset it with
QApplication::restoreOverrideCursor();.

Qt Creator 2.8.1 Qt 5.1.1 Qt Designer Linux Show a new Form

I am a beginner with Qt - so hopefully this will be an easy question to answer. I have a reasonable amount of experience with C++, that part is not a problem
The purpose of my application is to do code generation, initially to make header & implementation files for classes. I quite like the Class wizard on Code::Blocks, but I reckon I can do a lot more.
I have a main Widget which has a tabWidget & some lineEdit's & some pushButtons. To preview what will eventually be in the file, I have created a new Form, with a TextBrowser in it. The new Form entry appears in the .pro file.
I would like to have the new Form displayed when I press the pushButton, & I am intending to write text in the TextBrowser based on the contents of the lineEdit's in the main Widget.
I have been looking through the documentation all afternoon, but most of the examples show either a main widget or a Form by itself. I have seen the example of the Class Wizard (which is nearly what I want to do), but I would rather a tabWidget interface. Being able to open a Form from a button is a pretty basic thing to be able to do.
For some reason, the examples page in my QtCreator help doesn't show any examples - previous versions had heaps of examples. Not sure why that is.
Do I have my terminology mixed up - should I have a Dialog rather than a Form? Not sure what the difference is.
Apologies in advance if all this is in the documentation somewhere, I seem to spend hours trolling through it, so maybe someone could provide some links - that would be great.
Suppose the new form you created along with with header and cpp file is mynewform.h, mynewform.cpp and mynewform.ui
Now include mynewform.h in your mainwindow class,
and create an object of the class
mynewform myform;
In the clicked slot of pushbutton just type:
myform.show();
or
myform.exec(); //(if you want a blocking call)