我最近参加了Qt编程,并希望将我的应用程序移植到Qt.
我正在摆弄QPushButtons并且我设法在按钮中显示图像并将一些文本设置到按钮,但无论我做什么,无论有没有设计师,我都有同样的问题,文本对齐到图标而不是覆盖图标.
addButton = new QPushButton();
addButton->setIcon(QIcon(":/AddButton.png"));
addButton->setText(tr("+"));
addButton->setFlat(true);
addButton->setIconSize(QSize(100,90));
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
我知道有toolButton但它似乎没有"平面"属性.
有什么好主意吗?
非常感谢,
麦克风
我已经花了整整2天试图弄清楚如何使用NSViewControllers来创建一个多视图应用程序.
这就是我的工作.
我有2个视图控制器和MainMenu.xib的窗口.我还有一个AppController,它是两个视图控制器的委托.
当我启动应用程序时,我首先会遇到MainMenu.xib的Window视图,其中包含一个按钮.单击此按钮,IBAction将发送到appController,并要求SecondViewController显示它的nib.到目前为止,一切都很好,nib文件正确显示.
在secondViewController上,还有另一个按钮,它将另一个IBAction发送到appController,并要求显示FirstViewController,但没有任何反应,没有崩溃,没有警告......任何帮助都将非常感谢...提前感谢您的耐心等待. ..
这是AppController.h的代码:
#import <Foundation/Foundation.h>
#import "SecondViewController.h"
#import "FirstViewController.h"
@interface AppController : NSObject
@property (strong) IBOutlet NSWindow *mainWindow;
@property (strong) IBOutlet SecondViewController *secondViewController;
@property (strong) IBOutlet FirstViewController *firstViewController;
- (IBAction)secondButtonfromsecondViewControllerClicked:(id)sender;
- (IBAction)buttonClicked:(id)sender;
@end
Run Code Online (Sandbox Code Playgroud)
这是AppController.m的代码:
#import "AppController.h"
@implementation AppController
@synthesize mainWindow = mainwindow;
@synthesize secondViewController;
@synthesize firstViewController;
- (IBAction)buttonClicked:(id)sender {
NSLog(@"button from second View Controller clicked");
self.secondViewController = [[SecondViewController
alloc]initWithNibName:@"SecondViewController" bundle:nil];
self.mainWindow.contentView = self.secondViewController.view;
[self.secondViewController.view setAutoresizingMask:NSViewWidthSizable |
NSViewHeightSizable];
}
- (IBAction)secondButtonfromsecondViewControllerClicked:(id)sender {
NSLog(@"button from first ViewController clicked"); …
Run Code Online (Sandbox Code Playgroud) 我已经在这个问题上绞尽脑汁待了两天,我尝试了不同的东西,但没有一个能奏效.我正在构建一个应用程序,这是一种quizz.有三个主题包含问题.我想使用3个滑块来定义他们想要在每个主题上的问题百分比.
ex : slider one = History
slider two = Maths
slider three = Grammar
Run Code Online (Sandbox Code Playgroud)
如果我选择了更多的历史记录,我会向上滑动历史记录滑块,其他滑块应根据3个滑块的值达到100%而减少...
算法的任何想法?当一个滑块达到零值时会发生什么?
数学从来就不是我的场景.
任何帮助将非常感谢.
提前致谢.
麦克风
请你帮助我好吗 ?
我正在设置UILocalNotification,当我尝试设置其userInfo字典时,它会崩溃.fetchedObjects包含88个对象.
这是代码:
NSDictionary* myUserInfo = [NSDictionary dictionaryWithObject: fetchedObjects forKey: @"textbody"];
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
// défining the interval
NSTimeInterval oneMinute = 60;
localNotif.timeZone = [NSTimeZone localTimeZone];
NSDate *fireDate = [[NSDate alloc]initWithTimeIntervalSinceNow:oneMinute];
localNotif.fireDate = fireDate;
localNotif.userInfo = myUserInfo; //this is the line that crashes the app
[fetchedObjects release];
Run Code Online (Sandbox Code Playgroud)
而控制台给了我这个:
Property list invalid for format: 200
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'unable to serialize userInfo: (null)'
Run Code Online (Sandbox Code Playgroud)
任何的想法 ?
我正在用Qt构建我的App界面.但是出现了一个问题......我有一个QToolbar,我在其中添加了QToolButton和QToolbar-> addWidget方法.问题是我想稍后删除此按钮.
我怎样才能做到这一点?
有一个addWidget方法,但没有像removeWidget对应...
任何的想法 ?
非常感谢您的帮助.
迈克迈克